Linked GPowers and refactored FlairDoors

This commit is contained in:
alisolarflare 2016-11-05 07:59:35 -04:00
parent 48a30f8c7f
commit 0a01494c4a
6 changed files with 72 additions and 46 deletions

View file

@ -1,12 +1,9 @@
package alisolarflare.components.flairdoor.listeners;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -18,12 +15,9 @@ import org.bukkit.material.Wool;
import org.bukkit.plugin.java.JavaPlugin;
public class PortalListener implements Listener{
AbstractMap<String,Location> portalMap = new HashMap<String,Location>();
public static List<String> playersToBeFlaired = new ArrayList<String>();
public JavaPlugin plugin;
//TODO: CREATE - LIST OF PORTALS (only x-z values)
public PortalListener(JavaPlugin plugin) {
this.plugin = plugin;
@ -95,47 +89,54 @@ public class PortalListener implements Listener{
player.sendMessage("Recolouring Player as..." + dyecolour.toString());
String name = player.getName();
player.sendMessage("name:" + name);
String tempName = "";
for(int i = 0; i < name.length(); i++){
if (name.charAt(i) == '&'){
//TODO: Remove all &* symbols
name = name.substring(0, i) + name.substring(i + 1, name.length());
if (name.charAt(i) != '&'){
tempName += name.charAt(i);
}else{
i++;
}
}
name = tempName;
player.sendMessage("Adjusted Name: " + name);
if(dyecolour == DyeColor.GRAY){
switch(dyecolour){
case GRAY:
player.sendMessage("Adding GRAY");
player.setCustomName("&7" + name);
}else if(dyecolour == DyeColor.RED){
name = "&7" + name;
break;
case RED:
player.sendMessage("Adding RED");
player.setCustomName("&4" + name);
}else if(dyecolour == DyeColor.ORANGE){
name = "&4" + name;
break;
case ORANGE:
player.sendMessage("Adding ORANGE");
player.setCustomName("&6" + name);
}else if(dyecolour == DyeColor.YELLOW){
name = "&6" + name;
break;
case YELLOW:
player.sendMessage("Adding YELLOW");
player.setCustomName("&e" + name);
}else if(dyecolour == DyeColor.GREEN){
name = "&e" + name;
break;
case LIME:
case GREEN:
player.sendMessage("Adding GREEN");
player.setCustomName("&a" + name);
}else if(dyecolour == DyeColor.BLUE){
name = "&a" + name;
break;
case CYAN:
case LIGHT_BLUE:
case BLUE:
player.sendMessage("Adding BLUE");
player.setCustomName("&9" + name);
}else if(dyecolour == DyeColor.PURPLE){
name = "&9" + name;
break;
case PURPLE:
player.sendMessage("Adding PURPLE");
player.setCustomName("&5" + name);
}else{
name = "&5" + name;
break;
default:
player.sendMessage("ERROR, PORTAL HAS INVALID UNDER-BLOCK");
return;
break;
}
player.setCustomName(name);
player.sendMessage("Your name is now: " + player.getCustomName() +"! Removing you from playersToBeFlaired...");
playersToBeFlaired.remove(player.getName());
}

View file

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class GPowerMemory{
public Map<UUID, poweredPlayer> poweredPlayerList = new HashMap<UUID, poweredPlayer>();
public void PowerUpPlayer(Player player, String colour){
public void configurePlayer(Player player, String colour, boolean powerIsActive){
poweredPlayerList.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
}
public void PowerUpPlayer(Player player){

View file

@ -4,6 +4,8 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.Module;
import alisolarflare.components.gpowers.commands.GPower;
import alisolarflare.components.gpowers.commands.PowerDown;
import alisolarflare.components.gpowers.commands.PowerUp;
import alisolarflare.components.gpowers.listeners.gPowerListener;
public class GPowerModule extends Module {
@ -12,6 +14,8 @@ public class GPowerModule extends Module {
public void register(JavaPlugin plugin) {
GPowerMemory gPowerMemory = new GPowerMemory();
registerCommand(plugin, new GPower(gPowerMemory));
registerCommand(plugin, new PowerUp(gPowerMemory));
registerCommand(plugin, new PowerDown(gPowerMemory));
registerListener(plugin, new gPowerListener(plugin, gPowerMemory));
}

View file

@ -3,6 +3,8 @@ package alisolarflare.components.gpowers.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.mysql.fabric.xmlrpc.base.Data;
import alisolarflare.components.gpowers.GPowerMemory;
import buttondevteam.lib.chat.TBMCCommandBase;
@ -24,13 +26,12 @@ public class GPower extends TBMCCommandBase {
return false;
}
String colour;
player.sendMessage("Checking terms...");
if (args[0].startsWith("r") || args[0].startsWith("o") || args[0].startsWith("y") || args[0].startsWith("g")
|| args[0].startsWith("b") || args[0].startsWith("p")) {
colour = args[0];
} else {
player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]");
player.sendMessage("error: colour. Proper Usage to configure G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple,grey] [active=true/false]");
return false;
}
boolean isActive;
@ -39,16 +40,14 @@ public class GPower extends TBMCCommandBase {
} else if (args[1].startsWith("f")) {
isActive = false;
} else {
player.sendMessage("Term Fail: ACTIVE. Proper Usage to test G-Powers:");
player.sendMessage("error: active. Proper Usage to configure G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]");
return false;
}
player.sendMessage("Terms Vaild!");
if (isActive) {
gPowerMemory.PowerUpPlayer(player, colour);
} else {
gPowerMemory.PowerDownPlayer(player);
}
player.sendMessage("Saving Data: "+ player.getName() + "|" + colour + "|" + isActive);
gPowerMemory.configurePlayer(player, colour, isActive);
return false;
}

View file

@ -1,14 +1,25 @@
package alisolarflare.components.gpowers.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.components.gpowers.GPowerMemory;
import buttondevteam.lib.chat.TBMCCommandBase;
public class PowerDown extends TBMCCommandBase {
private GPowerMemory gPowerMemory;
public PowerDown(GPowerMemory gPowerMemory) {
this.gPowerMemory = gPowerMemory;
}
@Override
public boolean OnCommand(CommandSender arg0, String arg2, String[] arg3) {
// TODO Auto-generated method stub
public boolean OnCommand(CommandSender sender, String label, String[] args) {
if (!(sender instanceof Player))
sender.sendMessage("You must be a player to use this command! Contact dev/ali if you think this is wrong");
Player player = (Player) sender;
gPowerMemory.PowerDownPlayer(player);
return false;
}

View file

@ -1,14 +1,25 @@
package alisolarflare.components.gpowers.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.components.gpowers.GPowerMemory;
import buttondevteam.lib.chat.TBMCCommandBase;
public class PowerUp extends TBMCCommandBase {
private GPowerMemory gPowerMemory;
public PowerUp(GPowerMemory gPowerMemory) {
this.gPowerMemory = gPowerMemory;
}
@Override
public boolean OnCommand(CommandSender sender, String label, String[] args) {
// gPowerMemory.PowerUpPlayer(player, colour);
if (!(sender instanceof Player))
sender.sendMessage("You must be a player to use this command! Contact a dev/ali if you think this is wrong");
Player player = (Player) sender;
gPowerMemory.PowerUpPlayer(player);
return false;
}