diff --git a/Advanced Portals/src/com/sekwah/advancedportals/ConfigAccessor.java b/Advanced Portals/src/com/sekwah/advancedportals/ConfigAccessor.java new file mode 100644 index 0000000..d501479 --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/ConfigAccessor.java @@ -0,0 +1,71 @@ +package com.sekwah.advancedportals; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Level; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.java.JavaPlugin; + +public class ConfigAccessor { + + private final String fileName; + private final JavaPlugin plugin; + + private File configFile; + private FileConfiguration fileConfiguration; + + public ConfigAccessor(JavaPlugin plugin, String fileName) { + if (!plugin.isInitialized()) + throw new IllegalArgumentException("plugin must be initiaized"); + this.plugin = plugin; + this.fileName = fileName; + } + + // gets all of the + public void reloadConfig() { + if (configFile == null) { + File dataFolder = plugin.getDataFolder(); + if (dataFolder == null) + throw new IllegalStateException(); + configFile = new File(dataFolder, fileName); + } + fileConfiguration = YamlConfiguration.loadConfiguration(configFile); + + // Look for defaults in the jar + InputStream defConfigStream = plugin.getResource(fileName); + if (defConfigStream != null) { + YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); + fileConfiguration.setDefaults(defConfig); + } + } + + public FileConfiguration getConfig() { + if (fileConfiguration == null) { + this.reloadConfig(); + } + return fileConfiguration; + } + + // Saves all the data to the selected yml file + public void saveConfig() { + if (fileConfiguration == null || configFile == null) { + return; + } else { + try { + getConfig().save(configFile); + } catch (IOException ex) { + plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex); + } + } + } + + // Saves + public void saveDefaultConfig() { + if (!configFile.exists()) { + this.plugin.saveResource(fileName, false); + } + } + +} \ No newline at end of file diff --git a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java index 7996d7a..d17c6ae 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java @@ -1,9 +1,39 @@ package com.sekwah.advancedportals; -import org.bukkit.event.Listener; +import net.minecraft.server.v1_6_R3.Item; -public class Listeners implements Listener{ - +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; + +public class Listeners implements Listener { + @EventHandler + public void onMoveEvent(PlayerMoveEvent event) { + // will check if the player is in the portal or not. + + } + + + + + @EventHandler + public void oniteminteract(PlayerInteractEvent event) { + // will detect if the player is using an axe so the points of a portal can be set + // also any other detections such as sign interaction or basic block protection + if(event.getPlayer().getItemInHand().getTypeId() == Material.IRON_AXE.getId()) { + if(event.getAction() == Action.LEFT_CLICK_BLOCK){ + + } + else if(event.getAction() == Action.RIGHT_CLICK_BLOCK) { + + } + } + } + + }