From bd42f930acae785abb189c042d5800bccfcf61a3 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Wed, 20 Nov 2013 21:36:01 +0000 Subject: [PATCH] Added the start of the code to log portals in the portal.yml --- .../AdvancedPortalsPlugin.java | 5 ++++ .../portalcontrolls/Portal.java | 28 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java index 6cc3469a..a9e1e7ca 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java @@ -2,6 +2,8 @@ package com.sekwah.advancedportals; import org.bukkit.plugin.java.JavaPlugin; +import com.sekwah.advancedportals.portalcontrolls.Portal; + public class AdvancedPortalsPlugin extends JavaPlugin { public void onEnable() { @@ -17,6 +19,9 @@ public class AdvancedPortalsPlugin extends JavaPlugin { // Loads the current portal data new Portals(this); + // Loads the portal and destination editors + new Portal(this); + // These register the commands new AdvancedPortalsCommand(this); new DestinationCommand(this); diff --git a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java index 4845422b..9c74ad51 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java @@ -1,19 +1,41 @@ package com.sekwah.advancedportals.portalcontrolls; +import java.util.List; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; +import com.sekwah.advancedportals.AdvancedPortalsPlugin; +import com.sekwah.advancedportals.ConfigAccessor; + public class Portal { + + private static AdvancedPortalsPlugin plugin; + + public Portal(AdvancedPortalsPlugin plugin) { + this.plugin = plugin; + } public static void create(Player player, Material triggerBlockId, Location pos1, Location pos2 , String name) { - // TODO Auto-generated method stub } - public static void create(Player player, Location pos1, Location pos2, String name) { - // TODO Auto-generated method stub + public static void create(Player player, Location pos1, Location pos2, String name) { // add stuff for destination names or coordinates + ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml"); + config.getConfig().set("portals." + name + ".world", pos1.getWorld().getName()); + config.getConfig().set("portals." + name + ".hastriggerblock", false); + + config.getConfig().set("portals." + name + ".pos1.X", pos1.getX()); + config.getConfig().set("portals." + name + ".pos1.Y", pos1.getY()); + config.getConfig().set("portals." + name + ".pos1.Z", pos1.getZ()); + + config.getConfig().set("portals." + name + ".pos2.X", pos2.getX()); + config.getConfig().set("portals." + name + ".pos2.Y", pos2.getY()); + config.getConfig().set("portals." + name + ".pos2.Z", pos2.getZ()); + + config.getConfig().set("portals." + name + ".creator", player.getName()); } public static void redefine(Player player, Location pos1, Location pos2, String name){