mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-25 18:37:43 +01:00
Completely recoded the portal data system so it stores the data in a
cleaner way.
This commit is contained in:
parent
08d2f60e64
commit
a3ec952e10
@ -66,3 +66,4 @@ useCustomPrefix: false
|
||||
|
||||
customPrefix: '[Test]'
|
||||
|
||||
|
||||
|
@ -6,9 +6,9 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R1.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_7_R3.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutChat;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -17,7 +17,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
@ -46,18 +46,10 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
if(args[0].toLowerCase().equals("wand") || args[0].toLowerCase().equals("selector")){
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
Material WandMaterial;
|
||||
|
||||
try
|
||||
{
|
||||
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
|
||||
Material WandMaterial = Material.getMaterial(ItemID);
|
||||
|
||||
if(WandMaterial == null){
|
||||
WandMaterial = Material.IRON_AXE;
|
||||
@ -155,32 +147,18 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
Material triggerBlockMat = Material.getMaterial(0);
|
||||
if(hasTriggerBlock){
|
||||
|
||||
try
|
||||
{
|
||||
triggerBlockMat = Material.getMaterial(Integer.parseInt(triggerBlock));
|
||||
player.sendMessage("§atriggerBlock: §e" + triggerBlock.toUpperCase());
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, addArgs));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
try
|
||||
{
|
||||
triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase());
|
||||
player.sendMessage("§atriggerBlock: §e" + triggerBlock.toUpperCase());
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, addArgs));
|
||||
if(triggerBlockMat != null){
|
||||
player.sendMessage("§atriggerBlock: §e" + triggerBlock.toUpperCase());
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, addArgs));;
}
|
||||
else{
|
||||
hasTriggerBlock = false;
|
||||
ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml");
|
||||
player.sendMessage("§ctriggerBlock: §edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
|
||||
|
||||
player.sendMessage("§cThe block " + triggerBlock.toUpperCase() + " is not a valid block name in minecraft so the trigger block has been set to the default!");
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, addArgs));
|
||||
}
|
||||
catch(Exception exeption)
|
||||
{
|
||||
hasTriggerBlock = false;
|
||||
ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml");
|
||||
player.sendMessage("§ctriggerBlock: §edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
|
||||
|
||||
player.sendMessage("§cThe block " + triggerBlock.toUpperCase() + " is not a valid block name in minecraft so the trigger block has been set to the default!");
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, addArgs));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml");
|
||||
|
@ -36,7 +36,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
|
||||
if(posX == null){
|
||||
sender.sendMessage("§a[§eAdvancedPortals§a] You have created a new destination called " + args[1] + "!");
|
||||
sender.sendMessage("§a[§eAdvancedPortals§a] You have created a new destination called §e" + args[1] + "!");
|
||||
Player player = sender.getServer().getPlayer(sender.getName());
|
||||
Destination.create(player.getLocation(), args[1]);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
|
||||
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portalcontrolls.Portal;
|
||||
|
||||
public class FlowStopper implements Listener {
|
||||
@ -35,14 +36,14 @@ public class FlowStopper implements Listener {
|
||||
Block blockTo = event.getToBlock();
|
||||
Block block = event.getBlock();
|
||||
|
||||
Object[] portals = Portal.Portals;
|
||||
AdvancedPortal[] portals = Portal.Portals;
|
||||
int portalId = 0;
|
||||
for(Object portal : portals){
|
||||
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((Portal.pos1[portalId].getX() + 3D) >= block.getX() && (Portal.pos1[portalId].getY() + 3D) >= block.getY() && (Portal.pos1[portalId].getZ() + 3D) >= block.getZ()){
|
||||
if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){
|
||||
|
||||
if((Portal.pos2[portalId].getX() - 3D) <= block.getX() && (Portal.pos2[portalId].getY() - 3D) <= block.getY() && (Portal.pos2[portalId].getZ() - 3D) <= block.getZ()){
|
||||
if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -51,11 +52,11 @@ public class FlowStopper implements Listener {
|
||||
|
||||
}
|
||||
|
||||
if(Portal.worldName[portalId].equals(blockTo.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].worldName.equals(blockTo.getWorld().getName())){
|
||||
|
||||
if((Portal.pos1[portalId].getX() + 3D) >= blockTo.getX() && (Portal.pos1[portalId].getY() + 3D) >= blockTo.getY() && (Portal.pos1[portalId].getZ() + 3D) >= blockTo.getZ()){
|
||||
if((Portal.Portals[portalId].pos1.getX() + 3D) >= blockTo.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= blockTo.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= blockTo.getZ()){
|
||||
|
||||
if((Portal.pos2[portalId].getX() - 3D) <= blockTo.getX() && (Portal.pos2[portalId].getY() - 3D) <= blockTo.getY() && (Portal.pos2[portalId].getZ() - 3D) <= blockTo.getZ()){
|
||||
if((Portal.Portals[portalId].pos2.getX() - 3D) <= blockTo.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= blockTo.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= blockTo.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
|
@ -12,10 +12,11 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.sekwah.advancedportals.DataCollector.DataCollector;
|
||||
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portalcontrolls.Portal;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
@ -81,21 +82,21 @@ public class Listeners implements Listener {
|
||||
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;
|
||||
AdvancedPortal[] portals = Portal.Portals;
|
||||
int portalId = 0;
|
||||
for(Object portal : portals){
|
||||
if(Portal.worldName[portalId].equals(loc.getWorld().getName())){
|
||||
if(Portal.triggers[portalId].equals(loc.getBlock().getType())
|
||||
|| Portal.triggers[portalId].equals(eyeloc.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()){
|
||||
for(AdvancedPortal portal : portals){
|
||||
if(Portal.Portals[portalId].worldName.equals(loc.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].trigger.equals(loc.getBlock().getType())
|
||||
|| Portal.Portals[portalId].trigger.equals(eyeloc.getBlock().getType())){
|
||||
if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){
|
||||
if(Portal.Portals[portalId].pos2.getX() <= loc.getX() && Portal.Portals[portalId].pos2.getY() <= loc.getY() && Portal.Portals[portalId].pos2.getZ() <= loc.getZ()){
|
||||
|
||||
|
||||
boolean warped = Portal.activate(player, portal.toString());
|
||||
boolean warped = Portal.activate(player, portal.portalName);
|
||||
if(defaultPortalMessages && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
player.sendMessage("");
|
||||
player.sendMessage("§a[§eAdvancedPortals§a] You have warped to §e" + config.getConfig().getString(portal.toString() + ".destination") + ".");
|
||||
player.sendMessage("§a[§eAdvancedPortals§a] You have warped to §e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination") + ".");
|
||||
player.sendMessage("");
|
||||
}
|
||||
|
||||
@ -107,7 +108,7 @@ public class Listeners implements Listener {
|
||||
DataCollector.playerWarped();
|
||||
}
|
||||
|
||||
if(Portal.triggers[portalId].equals(Material.PORTAL)){
|
||||
if(Portal.Portals[portalId].trigger.equals(Material.PORTAL)){
|
||||
final Player finalplayer = event.getPlayer();
|
||||
if(player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
player.setMetadata("HasWarped", new FixedMetadataValue(plugin, true));
|
||||
@ -147,11 +148,11 @@ public class Listeners implements Listener {
|
||||
Object[] portals = Portal.Portals;
|
||||
int portalId = 0;
|
||||
for(Object portal : portals){
|
||||
if(Portal.worldName[portalId].equals(player.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].worldName.equals(player.getWorld().getName())){
|
||||
|
||||
if((Portal.pos1[portalId].getX() + 1D) >= loc.getX() && (Portal.pos1[portalId].getY() + 1D) >= loc.getY() && (Portal.pos1[portalId].getZ() + 1D) >= loc.getZ()){
|
||||
if((Portal.Portals[portalId].pos1.getX() + 1D) >= loc.getX() && (Portal.Portals[portalId].pos1.getY() + 1D) >= loc.getY() && (Portal.Portals[portalId].pos1.getZ() + 1D) >= loc.getZ()){
|
||||
|
||||
if((Portal.pos2[portalId].getX()) <= loc.getX() && (Portal.pos2[portalId].getY()) <= loc.getY() && (Portal.pos2[portalId].getZ()) <= loc.getZ()){
|
||||
if((Portal.Portals[portalId].pos2.getX()) <= loc.getX() && (Portal.Portals[portalId].pos2.getY()) <= loc.getY() && (Portal.Portals[portalId].pos2.getZ()) <= loc.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -178,16 +179,16 @@ public class Listeners implements Listener {
|
||||
Object[] portals = Portal.Portals;
|
||||
int portalId = 0;
|
||||
for(Object portal : portals){
|
||||
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((Portal.pos1[portalId].getX() + 3D) >= block.getX() && (Portal.pos1[portalId].getY() + 3D) >= block.getY() && (Portal.pos1[portalId].getZ() + 3D) >= block.getZ()){
|
||||
if((Portal.Portals[portalId].pos1.getX() + 3D) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + 3D) >= block.getY() && (Portal.Portals[portalId].pos1.getZ() + 3D) >= block.getZ()){
|
||||
|
||||
if((Portal.pos2[portalId].getX() - 3D) <= block.getX() && (Portal.pos2[portalId].getY() - 3D) <= block.getY() && (Portal.pos2[portalId].getZ() - 3D) <= block.getZ()){
|
||||
player.sendMessage("§a[§eAdvancedPortals§a] You have selected: §e" + Portal.portalName[portalId]);
|
||||
if((Portal.Portals[portalId].pos2.getX() - 3D) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - 3D) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - 3D) <= block.getZ()){
|
||||
player.sendMessage("§a[§eAdvancedPortals§a] You have selected: §e" + Portal.Portals[portalId].portalName);
|
||||
// TODO add code somewhere so when a portal is removed or changed if someone has it selected it notifies them
|
||||
// or removed their selections and tells them, maybe not before this update.
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, Portal.portalName[portalId])); // adds the name to the metadata of the character
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, Portal.Portals[portalId].portalName)); // adds the name to the metadata of the character
|
||||
event.setCancelled(true);
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
return;
|
||||
|
@ -47,11 +47,11 @@ public class PortalProtect implements Listener {
|
||||
Object[] portals = Portal.Portals;
|
||||
int portalId = 0;
|
||||
for(Object portal : portals){
|
||||
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].worldName.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.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.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()){
|
||||
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -72,11 +72,11 @@ public class PortalProtect implements Listener {
|
||||
Object[] portals = Portal.Portals;
|
||||
int portalId = 0;
|
||||
for(Object portal : portals){
|
||||
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].worldName.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.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.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()){
|
||||
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -96,11 +96,11 @@ public class PortalProtect implements Listener {
|
||||
Object[] portals = Portal.Portals;
|
||||
int portalId = 0;
|
||||
for(Object portal : portals){ // change for format for(int i = 0; i < portals.length; i++){
|
||||
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
|
||||
if(Portal.Portals[portalId].worldName.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.Portals[portalId].pos1.getX() + PortalProtectionRadius) >= block.getX() && (Portal.Portals[portalId].pos1.getY() + PortalProtectionRadius) >= block.getY() && (Portal.Portals[portalId].pos1.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()){
|
||||
if((Portal.Portals[portalId].pos2.getX() - PortalProtectionRadius) <= block.getX() && (Portal.Portals[portalId].pos2.getY() - PortalProtectionRadius) <= block.getY() && (Portal.Portals[portalId].pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
|
||||
blockList.remove(i);
|
||||
i--;
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.sekwah.advancedportals.portalcontrolls;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class AdvancedPortal {
|
||||
|
||||
public Material trigger = null;
|
||||
|
||||
public String worldName = null;
|
||||
|
||||
public Location pos1 = null;
|
||||
|
||||
public Location pos2 = null;
|
||||
|
||||
public String portalName = null;
|
||||
}
|
@ -5,12 +5,10 @@ import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
@ -25,17 +23,7 @@ public class Portal {
|
||||
|
||||
public static boolean portalsActive = true;
|
||||
|
||||
public static Object[] Portals;
|
||||
|
||||
public static Material[] triggers;
|
||||
|
||||
public static String[] worldName;
|
||||
|
||||
public static Location[] pos1;
|
||||
|
||||
public static Location[] pos2;
|
||||
|
||||
public static String[] portalName;
|
||||
public static AdvancedPortal[] Portals;
|
||||
|
||||
public Portal(AdvancedPortalsPlugin plugin) {
|
||||
Portal.plugin = plugin;
|
||||
@ -51,38 +39,44 @@ public class Portal {
|
||||
*
|
||||
*/
|
||||
|
||||
public static void loadPortals(){
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void loadPortals(){
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
Set<String> PortalSet = config.getConfig().getKeys(false);
|
||||
if(PortalSet.size() > 0){
|
||||
Portals = PortalSet.toArray();
|
||||
portalName = new String[Portals.length];
|
||||
// allocates the memory for the arrays
|
||||
worldName = new String[Portals.length];
|
||||
triggers = new Material[Portals.length];
|
||||
pos1 = new Location[Portals.length];
|
||||
pos2 = new Location[Portals.length];
|
||||
Portals = new AdvancedPortal[PortalSet.toArray().length];
|
||||
|
||||
for(int i = 0; i <= PortalSet.toArray().length - 1; i++){
|
||||
Portals[i] = new AdvancedPortal();
|
||||
}
|
||||
|
||||
int portalId = 0;
|
||||
for(Object portal: Portals){
|
||||
for(Object portal: PortalSet.toArray()){
|
||||
|
||||
Material blockType;
|
||||
Material blockType = Material.PORTAL;
|
||||
String BlockID = config.getConfig().getString(portal.toString() + ".triggerblock");
|
||||
try
|
||||
{
|
||||
blockType = Material.getMaterial(Integer.parseInt(BlockID));
|
||||
Integer.parseInt(BlockID);
|
||||
System.out.println("Block names must be given not IDs");
|
||||
}
|
||||
catch(Exception e)
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
blockType = Material.getMaterial(BlockID);
|
||||
}
|
||||
triggers[portalId] = blockType;
|
||||
portalName[portalId] = portal.toString();
|
||||
worldName[portalId] = config.getConfig().getString(portal.toString() + ".world");
|
||||
|
||||
if(blockType == null){
|
||||
blockType = Material.PORTAL;
|
||||
}
|
||||
|
||||
Portals[portalId].trigger = blockType;
|
||||
System.out.println("Test: " + portal.toString());
|
||||
Portals[portalId].portalName = portal.toString();
|
||||
Portals[portalId].worldName = config.getConfig().getString(portal.toString() + ".world");
|
||||
World world = Bukkit.getWorld(config.getConfig().getString(portal.toString() + ".world"));
|
||||
pos1[portalId] = new Location(world, config.getConfig().getInt(portal.toString() + ".pos1.X"), config.getConfig().getInt(portal.toString() + ".pos1.Y"), config.getConfig().getInt(portal.toString() + ".pos1.Z"));
|
||||
pos2[portalId] = new Location(world, config.getConfig().getInt(portal.toString() + ".pos2.X"), config.getConfig().getInt(portal.toString() + ".pos2.Y"), config.getConfig().getInt(portal.toString() + ".pos2.Z"));
|
||||
Portals[portalId].pos1 = new Location(world, config.getConfig().getInt(portal.toString() + ".pos1.X"), config.getConfig().getInt(portal.toString() + ".pos1.Y"), config.getConfig().getInt(portal.toString() + ".pos1.Z"));
|
||||
Portals[portalId].pos2 = new Location(world, config.getConfig().getInt(portal.toString() + ".pos2.X"), config.getConfig().getInt(portal.toString() + ".pos2.Y"), config.getConfig().getInt(portal.toString() + ".pos2.Z"));
|
||||
|
||||
portalId++;
|
||||
}
|
||||
@ -170,27 +164,28 @@ public class Portal {
|
||||
// make this actually work!
|
||||
private static boolean checkPortalOverlap(Location pos1, Location pos2) {
|
||||
|
||||
|
||||
int portalId = 0;
|
||||
for(Object portal : Portal.Portals){
|
||||
if(Portal.worldName[portalId].equals(pos2.getWorld().getName())){ // checks that the cubes arnt overlapping by seeing if all 4 corners are not in side another
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos1[portalId].getBlockX(), Portal.pos1[portalId].getBlockY(), Portal.pos1[portalId].getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos1[portalId].getBlockX(), Portal.pos1[portalId].getBlockY(), Portal.pos2[portalId].getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos1[portalId].getBlockX(), Portal.pos2[portalId].getBlockY(), Portal.pos1[portalId].getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos2[portalId].getBlockX(), Portal.pos1[portalId].getBlockY(), Portal.pos1[portalId].getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos2[portalId].getBlockX(), Portal.pos2[portalId].getBlockY(), Portal.pos2[portalId].getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos2[portalId].getBlockX(), Portal.pos1[portalId].getBlockY(), Portal.pos2[portalId].getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos1[portalId].getBlockX(), Portal.pos2[portalId].getBlockY(), Portal.pos2[portalId].getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portal.pos2[portalId].getBlockX(), Portal.pos2[portalId].getBlockY(), Portal.pos1[portalId].getBlockZ())){return true;}
|
||||
if(portalsActive){
|
||||
int portalId = 0;
|
||||
for(@SuppressWarnings("unused") Object portal : Portal.Portals){
|
||||
if(Portals[portalId].worldName.equals(pos2.getWorld().getName())){ // checks that the cubes arnt overlapping by seeing if all 4 corners are not in side another
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
|
||||
|
||||
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
|
||||
}
|
||||
portalId++;
|
||||
}
|
||||
portalId++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user