From 828a57a21fe841f8beb47943086ff612550096e2 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sun, 21 Aug 2016 21:11:02 -0400 Subject: [PATCH] Started work on FlairDoors --- plugin.yml | 4 +- .../flairdoors/FlairDoorsSubPlug.java | 25 +++++++++++ .../flairdoors/PortalLightListener.java | 44 +++++++++++++++++++ .../flairdoors/SetFlairDoorColour.java | 44 +++++++++++++++++++ src/alisolarflare/links/AliLinkSubPlug.java | 7 +++ src/alisolarflare/links/Link.java | 5 +++ src/alisolarflare/links/Serializer.java | 2 +- 7 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 src/alisolarflare/flairdoors/FlairDoorsSubPlug.java create mode 100644 src/alisolarflare/flairdoors/PortalLightListener.java create mode 100644 src/alisolarflare/flairdoors/SetFlairDoorColour.java diff --git a/plugin.yml b/plugin.yml index e2d472c..6d46464 100644 --- a/plugin.yml +++ b/plugin.yml @@ -8,4 +8,6 @@ commands: pressalilink: description: Presses an Ali Link pressalilink frequency setalilink: - description: Creates an Ali Link setalilink frequency \ No newline at end of file + description: Creates an Ali Link setalilink frequency + setFlairDoorColour: + description: Sets the flair door colour mode, when lighting portals \ No newline at end of file diff --git a/src/alisolarflare/flairdoors/FlairDoorsSubPlug.java b/src/alisolarflare/flairdoors/FlairDoorsSubPlug.java new file mode 100644 index 0000000..70ac438 --- /dev/null +++ b/src/alisolarflare/flairdoors/FlairDoorsSubPlug.java @@ -0,0 +1,25 @@ +package alisolarflare.flairdoors; + +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.AliPresents; + +public class FlairDoorsSubPlug{ + private AliPresents plugin; + public FlairDoorsSubPlug(AliPresents plugin){ + this.plugin = plugin; + } + public void register(){ + registerCommands(); + registerEvents(); + } + private void registerCommands() { + plugin.getCommand("SetFlairDoorColour").setExecutor(new SetFlairDoorColour()); + + } + private void registerEvents() { + // TODO Auto-generated method stub + plugin.getServer().getPluginManager().registerEvents(new PortalLightListener(), plugin); + + } +} diff --git a/src/alisolarflare/flairdoors/PortalLightListener.java b/src/alisolarflare/flairdoors/PortalLightListener.java new file mode 100644 index 0000000..abb087e --- /dev/null +++ b/src/alisolarflare/flairdoors/PortalLightListener.java @@ -0,0 +1,44 @@ +package alisolarflare.flairdoors; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCreatePortalEvent; +import org.bukkit.event.entity.EntityPortalEvent; + +public class PortalLightListener implements Listener{ + + //TODO: CREATE - LIST OF PORTALS (only x-z values) + + + @EventHandler + public void onPortalLight(EntityCreatePortalEvent event){ + + //SANITATION - entity > player + if(!(event.getEntity() instanceof Player)){return;} + Player player = (Player) event.getEntity(); + + //SANITIATION - player > alisolarflare + if(!(player.getName() == "alisolarflare")){return;} + + //TODO: MARK PORTAL + if (SetFlairDoorColour.FlairDoorColorMode == "null"){ + player.sendMessage("Your Colour mode is set to Null, use /SetFlairDoorColour [Color] to specify a colour for this portal"); + return; + } + //TODO: SAVE PORTAL + } + + @EventHandler + public void onPortalEnter(EntityPortalEvent event){ + event.setCancelled(false); + + //TODO: IF PLAYER LOCATION IS INSIDE A COLOUR PORTAL + //TODO: IF PLAYER NOT FLAIRED + //TODO: IF PLAYERSTATE IS TRUE + //TODO: CHANGE CUSTOM DISPLAY NAME + //TODO: TELEPORT TO SPAWN + //TODO: MARK PLAYER AS COLOURED + + } +} diff --git a/src/alisolarflare/flairdoors/SetFlairDoorColour.java b/src/alisolarflare/flairdoors/SetFlairDoorColour.java new file mode 100644 index 0000000..69df081 --- /dev/null +++ b/src/alisolarflare/flairdoors/SetFlairDoorColour.java @@ -0,0 +1,44 @@ +package alisolarflare.flairdoors; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class SetFlairDoorColour implements CommandExecutor { + public static String FlairDoorColorMode = "null"; + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length > 1){ + sender.sendMessage("You must specify and argument, Red-Purple or Null."); + } + + String firstCommand = args[0]; + firstCommand = firstCommand.toLowerCase(); + if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){ + sender.sendMessage("Flair Door Colour Mode set to grey"); + FlairDoorColorMode = "gray"; + }else if(firstCommand.startsWith("r")){ + sender.sendMessage("Flair Door Colour Mode set to Red"); + FlairDoorColorMode = "red"; + }else if(firstCommand.startsWith("o")){ + sender.sendMessage("Flair Door Colour Mode set to Orange"); + FlairDoorColorMode = "orange"; + }else if(firstCommand.startsWith("y")){ + sender.sendMessage("Flair Door Colour Mode set to Yellow"); + FlairDoorColorMode = "yellow"; + }else if(firstCommand.startsWith("g")){ + sender.sendMessage("Flair Door Colour Mode set to Green (use E for grey)"); + FlairDoorColorMode = "green"; + }else if(firstCommand.startsWith("b") || firstCommand.startsWith("i")){ + sender.sendMessage("Flair Door Colour Mode set to Blue"); + FlairDoorColorMode = "blue"; + }else if(firstCommand.startsWith("v") || firstCommand.startsWith("p")){ + sender.sendMessage("Flair Door Colour Mode set to Purple"); + FlairDoorColorMode = "purple"; + }else if(firstCommand.startsWith("n")){ + sender.sendMessage("Flair Door Colour Mode set to Null"); + FlairDoorColorMode = "null"; + } + return false; + } +} diff --git a/src/alisolarflare/links/AliLinkSubPlug.java b/src/alisolarflare/links/AliLinkSubPlug.java index 5c946a1..738bb52 100644 --- a/src/alisolarflare/links/AliLinkSubPlug.java +++ b/src/alisolarflare/links/AliLinkSubPlug.java @@ -32,5 +32,12 @@ public class AliLinkSubPlug{ plugin.getCommand("setalilink").setExecutor(new SetAliLink(this)); } + public void saveLinkList(){ + plugin.getConfig().set("aliLinkList", linkList); + } + @SuppressWarnings("unchecked") + public List loadLinkList(){ + return (List) plugin.getConfig().getList("aliLinkList"); + } } diff --git a/src/alisolarflare/links/Link.java b/src/alisolarflare/links/Link.java index 3f24142..9e1f973 100644 --- a/src/alisolarflare/links/Link.java +++ b/src/alisolarflare/links/Link.java @@ -12,7 +12,12 @@ 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; diff --git a/src/alisolarflare/links/Serializer.java b/src/alisolarflare/links/Serializer.java index 1b1172e..51cb0ac 100644 --- a/src/alisolarflare/links/Serializer.java +++ b/src/alisolarflare/links/Serializer.java @@ -15,7 +15,7 @@ public class Serializer { public void saveLinkList(List aliLinkList){ //saves link - + try{ FileOutputStream fout = new FileOutputStream("AliLinkList.ser");