diff --git a/AliPresents.jar b/AliPresents.jar
index 0a43358..432ac49 100644
Binary files a/AliPresents.jar and b/AliPresents.jar differ
diff --git a/config.yml b/config.yml
new file mode 100644
index 0000000..e69de29
diff --git a/src/alisolarflare/AliPresents.java b/src/alisolarflare/AliPresents.java
index b9b2484..b22456d 100644
--- a/src/alisolarflare/AliPresents.java
+++ b/src/alisolarflare/AliPresents.java
@@ -6,6 +6,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
import alisolarflare.flairdoors.PortalListener;
import alisolarflare.flairdoors.SetFlairDoorColour;
+import alisolarflare.links.AliLinkSubPlug;
+
//import alisolarflare.links.AliLinkSubPlug;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.shulker.AliShulker;
@@ -18,7 +20,7 @@ public class AliPresents extends JavaPlugin{
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
- //registerSubPlugins();
+ registerSubPlugins();
registerCommands();
registerEvents();
@@ -31,8 +33,8 @@ public class AliPresents extends JavaPlugin{
}
public void registerSubPlugins(){
- //AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this);
- //alilinksubplugin.register();
+ AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this);
+ alilinksubplugin.register();
}
public void registerCommands(){
getCommand("alishulker").setExecutor(new AliShulker());
diff --git a/src/alisolarflare/flairdoors/PortalListener.java b/src/alisolarflare/flairdoors/PortalListener.java
index ed7da82..a4bdea4 100644
--- a/src/alisolarflare/flairdoors/PortalListener.java
+++ b/src/alisolarflare/flairdoors/PortalListener.java
@@ -7,6 +7,7 @@ import org.bukkit.Location;
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.world.PortalCreateEvent;
@@ -22,6 +23,7 @@ public class PortalListener implements Listener{
public PortalListener(AliPresents plugin) {
this.plugin = plugin;
}
+
@EventHandler
public void onAliRightClick(PlayerInteractEvent event){
if (event.getPlayer().getName() != "alisolarflare"){
@@ -33,6 +35,9 @@ public class PortalListener implements Listener{
if(event.getItem().getType() != Material.FLINT_AND_STEEL && event.getItem().getType() != Material.FIREBALL){
return;
}
+ if(event.getAction() != Action.RIGHT_CLICK_BLOCK){
+ return;
+ }
plugin.getServer().broadcastMessage("RIIIIGHTCLICK");
}
diff --git a/src/alisolarflare/links/AliLinkSubPlug.java b/src/alisolarflare/links/AliLinkSubPlug.java
index 738bb52..08be881 100644
--- a/src/alisolarflare/links/AliLinkSubPlug.java
+++ b/src/alisolarflare/links/AliLinkSubPlug.java
@@ -1,29 +1,22 @@
package alisolarflare.links;
-
import java.util.ArrayList;
import java.util.List;
import alisolarflare.AliPresents;
+import alisolarflare.links.commands.PressAliLink;
+import alisolarflare.links.commands.SetAliLink;
+import alisolarflare.links.entities.Link;
public class AliLinkSubPlug{
- public List linkList;
+ public List linkList = new ArrayList();
public AliPresents plugin;
- public Serializer serializer;
- public Deserializer deserializer;
+ @SuppressWarnings("unchecked")
public AliLinkSubPlug(AliPresents plugin){
this.plugin = plugin;
- this.serializer = new Serializer();
- this.deserializer = new Deserializer();
- try{
- this.linkList = deserializer.loadLinkList();
- if(this.linkList == null){
- this.linkList = new ArrayList();
- serializer.saveLinkList(this.linkList);
- }
- }catch(Exception e){
+ linkList = (List) plugin.getConfig().getList("aliLinkList");
+ if(linkList == null || linkList.isEmpty()){
linkList = new ArrayList();
- serializer.saveLinkList(this.linkList);
}
}
diff --git a/src/alisolarflare/links/Link.java b/src/alisolarflare/links/Link.java
deleted file mode 100644
index 9e1f973..0000000
--- a/src/alisolarflare/links/Link.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package alisolarflare.links;
-
-import java.io.Serializable;
-
-import org.bukkit.Location;
-import org.bukkit.Material;
-
-public class Link implements Serializable{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- AliLinkSubPlug subplugin;
- String frequency;
- String world;
- Location location;
- int x;
- int y;
- int z;
-
-
- public Link(AliLinkSubPlug plugin, String frequency, Location location){
- this.frequency = frequency;
- this.location = location;
- this.subplugin = plugin;
- plugin.plugin.getConfig().set("frequency", 10);
- }
- public void press() {
- location.getBlock().setType(Material.REDSTONE_BLOCK);
- UnpressTask unPressTask = new UnpressTask(location);
- unPressTask.runTaskTimer(subplugin.plugin, 2, 1);
- }
-}
diff --git a/src/alisolarflare/links/SetAliLink.java b/src/alisolarflare/links/SetAliLink.java
deleted file mode 100644
index 4cf52bd..0000000
--- a/src/alisolarflare/links/SetAliLink.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package alisolarflare.links;
-
-import org.apache.commons.lang3.StringUtils;
-import org.bukkit.Location;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-public class SetAliLink implements CommandExecutor{
- AliLinkSubPlug subplugin;
- public SetAliLink(AliLinkSubPlug plugin){
- this.subplugin = plugin;
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (args == null){
- sender.sendMessage("You must specify a link frequency");
- sender.sendMessage("/pressalilink [name]");
- }
- if (!(sender instanceof Player)){
- sender.sendMessage("You must be a player to use this command!");
- }
- Player player = (Player) sender;
- if (args.length < 4){
- subplugin.linkList.add(new Link(subplugin, args[0], player.getLocation()));
- subplugin.serializer.saveLinkList(subplugin.linkList);
- return false;
- }
- if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2]) && StringUtils.isNumericSpace(args[3])){
- subplugin.linkList.add(new Link(subplugin, args[0],new Location(player.getWorld(), Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3]))));
- subplugin.serializer.saveLinkList(subplugin.linkList);
- }else{
- subplugin.linkList.add(new Link(subplugin, args[0], player.getLocation()));
- subplugin.serializer.saveLinkList(subplugin.linkList);
- return false;
- }
- return false;
- }
-
-}
diff --git a/src/alisolarflare/links/PressAliLink.java b/src/alisolarflare/links/commands/PressAliLink.java
similarity index 71%
rename from src/alisolarflare/links/PressAliLink.java
rename to src/alisolarflare/links/commands/PressAliLink.java
index 994857d..ba39b6e 100644
--- a/src/alisolarflare/links/PressAliLink.java
+++ b/src/alisolarflare/links/commands/PressAliLink.java
@@ -1,9 +1,12 @@
-package alisolarflare.links;
+package alisolarflare.links.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
+import alisolarflare.links.AliLinkSubPlug;
+import alisolarflare.links.entities.Link;
+
public class PressAliLink implements CommandExecutor{
private AliLinkSubPlug subplugin;
public PressAliLink(AliLinkSubPlug subplugin){
@@ -11,14 +14,17 @@ public class PressAliLink implements CommandExecutor{
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (args == null){
+
+ subplugin.plugin.getServer().broadcastMessage(subplugin.linkList.toString() + "over.");
+
+ if (args.length < 1){
sender.sendMessage("You must specify a link frequency");
sender.sendMessage("/pressalilink [frequency]");
}
for (Link link: subplugin.linkList){
for (String inputlink: args){
if(inputlink.equals(link.frequency)){
- link.press();
+ link.press(subplugin);
}
}
}
diff --git a/src/alisolarflare/links/commands/SetAliLink.java b/src/alisolarflare/links/commands/SetAliLink.java
new file mode 100644
index 0000000..f44e364
--- /dev/null
+++ b/src/alisolarflare/links/commands/SetAliLink.java
@@ -0,0 +1,67 @@
+package alisolarflare.links.commands;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.bukkit.Location;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import alisolarflare.links.AliLinkSubPlug;
+import alisolarflare.links.entities.Link;
+
+public class SetAliLink implements CommandExecutor{
+ AliLinkSubPlug subplugin;
+ public SetAliLink(AliLinkSubPlug plugin){
+ this.subplugin = plugin;
+ }
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ sender.sendMessage("you pressed shit");
+ if (args == null || args.length < 1){
+ sender.sendMessage("You must specify a link frequency");
+ sender.sendMessage("/pressalilink [name]");
+ return false;
+ }
+ if (!(sender instanceof Player)){
+ sender.sendMessage("You must be a player to use this command!");
+ }
+ Player player = (Player) sender;
+ if (args.length < 4){
+ player.sendMessage("short");
+ subplugin.linkList.add(new Link(args[0], player.getLocation()));
+ save(player);
+ player.sendMessage("end");
+ return false;
+ }
+ if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2]) && StringUtils.isNumericSpace(args[3])){
+ player.sendMessage("CUUUSTOM");
+ subplugin.linkList.add(new Link(args[0],new Location(player.getWorld(), Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3]))));
+ save(player);
+ player.sendMessage("FINISHED");
+ }else{
+ player.sendMessage("UNCUSTOOM");
+ subplugin.linkList.add(new Link(args[0], player.getLocation()));
+ save(player);
+ player.sendMessage("UNFINISHED");
+ return false;
+ }
+ return false;
+ }
+ private void save(Player player){
+ player.sendMessage("SAAAVING");
+ subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList);
+ try {
+ player.sendMessage("SAVIN");
+ subplugin.plugin.getConfig().save("aliLinkList");
+ player.sendMessage("GOOD SAVE");
+ } catch (IOException e) {
+ player.sendMessage("YOU FUCKED STUFF UP");
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/alisolarflare/links/entities/Link.java b/src/alisolarflare/links/entities/Link.java
new file mode 100644
index 0000000..f8c2e1d
--- /dev/null
+++ b/src/alisolarflare/links/entities/Link.java
@@ -0,0 +1,37 @@
+package alisolarflare.links.entities;
+
+import java.io.Serializable;
+
+import org.bukkit.Location;
+import org.bukkit.Material;
+
+import alisolarflare.links.AliLinkSubPlug;
+import alisolarflare.links.tasks.UnpressTask;
+
+public class Link implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public String frequency;
+ String world;
+ String x;
+ String y;
+ String z;
+
+
+ public Link(String frequency, Location location){
+ this.frequency = frequency;
+ this.world = location.getWorld().getName();
+ this.x = "" + location.getBlockX();
+ this.y = "" + location.getBlockY();
+ this.z = "" + location.getBlockZ();
+ //plugin.plugin.getConfig().set("frequency", 10);
+ }
+ public void press(AliLinkSubPlug plugin) {
+ Location location = new Location(plugin.plugin.getServer().getWorld(world), Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z));
+ location.getBlock().setType(Material.REDSTONE_BLOCK);
+ UnpressTask unPressTask = new UnpressTask(location);
+ unPressTask.runTaskTimer(plugin.plugin, 2, 1);
+ }
+}
diff --git a/src/alisolarflare/links/Deserializer.java b/src/alisolarflare/links/serializer/Deserializer.java
similarity index 89%
rename from src/alisolarflare/links/Deserializer.java
rename to src/alisolarflare/links/serializer/Deserializer.java
index 437b16e..db5da86 100644
--- a/src/alisolarflare/links/Deserializer.java
+++ b/src/alisolarflare/links/serializer/Deserializer.java
@@ -1,10 +1,12 @@
-package alisolarflare.links;
+package alisolarflare.links.serializer;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.List;
+import alisolarflare.links.entities.Link;
+
public class Deserializer{
public static void main (String args[]) {
diff --git a/src/alisolarflare/links/Serializer.java b/src/alisolarflare/links/serializer/Serializer.java
similarity index 87%
rename from src/alisolarflare/links/Serializer.java
rename to src/alisolarflare/links/serializer/Serializer.java
index 51cb0ac..f05ab1b 100644
--- a/src/alisolarflare/links/Serializer.java
+++ b/src/alisolarflare/links/serializer/Serializer.java
@@ -1,10 +1,12 @@
-package alisolarflare.links;
+package alisolarflare.links.serializer;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.List;
+import alisolarflare.links.entities.Link;
+
public class Serializer {
public static void main (String args[]) {
diff --git a/src/alisolarflare/links/UnpressTask.java b/src/alisolarflare/links/tasks/UnpressTask.java
similarity index 92%
rename from src/alisolarflare/links/UnpressTask.java
rename to src/alisolarflare/links/tasks/UnpressTask.java
index 946c2c7..c65c76f 100644
--- a/src/alisolarflare/links/UnpressTask.java
+++ b/src/alisolarflare/links/tasks/UnpressTask.java
@@ -1,4 +1,4 @@
-package alisolarflare.links;
+package alisolarflare.links.tasks;
import org.bukkit.Location;
import org.bukkit.Material;