Added a portal Listener class

This commit is contained in:
alisolarflare 2016-08-25 01:21:19 -04:00
parent 828a57a21f
commit bcd18f7d39
6 changed files with 75 additions and 49 deletions

Binary file not shown.

View file

@ -1,7 +1,5 @@
package alisolarflare.flairdoors; package alisolarflare.flairdoors;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
public class FlairDoorsSubPlug{ public class FlairDoorsSubPlug{
@ -19,7 +17,7 @@ public class FlairDoorsSubPlug{
} }
private void registerEvents() { private void registerEvents() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
plugin.getServer().getPluginManager().registerEvents(new PortalLightListener(), plugin); plugin.getServer().getPluginManager().registerEvents(new PortalListener(plugin), plugin);
} }
} }

View file

@ -1,44 +0,0 @@
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
}
}

View file

@ -0,0 +1,68 @@
package alisolarflare.flairdoors;
import java.util.AbstractMap;
import java.util.HashMap;
import org.bukkit.Location;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCreatePortalEvent;
import alisolarflare.AliPresents;
public class PortalListener implements Listener{
AbstractMap<String,Location> portalMap = new HashMap<String,Location>();
private AliPresents plugin;
//TODO: CREATE - LIST OF PORTALS (only x-z values)
public PortalListener(AliPresents plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPortalLight(EntityCreatePortalEvent event){
plugin.getServer().broadcastMessage("PORTAL LIT WHOOP WHOOP");
plugin.getServer().broadcastMessage(event.getEntity().getName());
//SANITATION - entity > player
if(!(event.getEntity() instanceof Player)){return;}
Player player = (Player) event.getEntity();
event.getEntity().getServer().broadcastMessage(player.getName());
//SANITIATION - player > alisolarflare
if(!(player.getName() == "alisolarflare")){return;}
event.getEntity().getServer().broadcastMessage(SetFlairDoorColour.FlairDoorColorMode);
//SANITATION - FlairDoorColourMode
if (SetFlairDoorColour.FlairDoorColorMode == "null"){
player.sendMessage("Your Colour mode is set to Null, use /SetFlairDoorColour [Color] to specify a colour for this portal");
return;
}
//INIT - colourMode, portalLocation
String colourMode = SetFlairDoorColour.FlairDoorColorMode;
Location portalLocation = event.getBlocks().get(0).getBlock().getLocation();
event.getEntity().getServer().broadcastMessage(portalLocation.toString());
//SAVE - Portal
if(SetFlairDoorColour.COLOURMODES.contains(colourMode)){
for (BlockState blockstate : event.getBlocks()){
player.sendMessage(blockstate.getBlock().getLocation().toString());
}
portalMap.put(colourMode, portalLocation);
}
}
/*
@EventHandler
public void onPortalEnter(EntityPortalEvent event){
//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
}
*/
}

View file

@ -1,11 +1,15 @@
package alisolarflare.flairdoors; package alisolarflare.flairdoors;
import java.util.Arrays;
import java.util.List;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class SetFlairDoorColour implements CommandExecutor { public class SetFlairDoorColour implements CommandExecutor {
public static String FlairDoorColorMode = "null"; public static String FlairDoorColorMode = "null";
public static final List<String> COLOURMODES = Arrays.asList("red", "orange", "yellow", "green", "blue", "purple", "gray");
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 1){ if (args.length > 1){
@ -15,7 +19,7 @@ public class SetFlairDoorColour implements CommandExecutor {
String firstCommand = args[0]; String firstCommand = args[0];
firstCommand = firstCommand.toLowerCase(); firstCommand = firstCommand.toLowerCase();
if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){ if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){
sender.sendMessage("Flair Door Colour Mode set to grey"); sender.sendMessage("Flair Door Colour Mode set to gray");
FlairDoorColorMode = "gray"; FlairDoorColorMode = "gray";
}else if(firstCommand.startsWith("r")){ }else if(firstCommand.startsWith("r")){
sender.sendMessage("Flair Door Colour Mode set to Red"); sender.sendMessage("Flair Door Colour Mode set to Red");