Ali #20

Merged
alisolarflare merged 3 commits from Ali into master 2016-11-06 22:18:56 +00:00
16 changed files with 157 additions and 37 deletions

View file

@ -29,6 +29,8 @@ commands:
description: List all fighters currently in a button minigame
setcolourspawn:
description: sets the spawn points for each colour in a button minigame
setmatchstate:
description: sets the current state of the ultrahardcore game.
addtouhc:
description: Adds a player to the UltraHardcore match
joinuhc:

View file

@ -18,10 +18,10 @@ public class AliPresents extends JavaPlugin{
public void onEnable(){
PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
new FlairDoorModule().register(this);
new GPowerModule().register(this);
new AliLinkModule().register(this);
@ -30,6 +30,7 @@ public class AliPresents extends JavaPlugin{
new MinigameModule().register(this);
new CreativeBoundariesModule().register(this);
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");

View file

@ -8,10 +8,10 @@ import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.chat.TBMCCommandBase;
/**
* A Module class is a helper class that allows the compacting of projects into one single package.
* Each feature, whether game, arrow trail listener, or command tool, can have its command and listener
* registration coded into the Module class, as well as any other pointers to memory units, or other
* classes in the package.
* A Module class allows the compacting of projects into one single package.
*
* Each feature can have its commands and listeners coded into the Module class,
* as well as any other pointers to memory units, or other classes in the package.
*
* This package can then be moved from eclipse project to eclipse project smoothly,
* as long as the destination project has the Module abstract class, and as long as all dependencies are either
@ -21,19 +21,14 @@ import buttondevteam.lib.chat.TBMCCommandBase;
*/
public abstract class Module{
/**
* Registers the project, when called by the Main JavaPlugin class that handles
* the main plugin.
* Registers the module, when called by the JavaPlugin class. Call
* registerCommand() and registerListener() within this method.
*
* To register a command, call plugin.getCommand(//label).setExecutor(//commandExecutor); where
* label is a string containing the name of the command in plugin.yml, and where commandExecutor
* is a class implementing command executor
*
* To register a listener,
* @param plugin Plugin class called to register commands and listeners
*/
public abstract void register(JavaPlugin plugin);
/**
* Lazy route to type plugin.getCommand("label").setExecutor
* Registers a TBMCCommand to the plugin
* @param plugin Main plugin responsible for stuff
* @param label Name of the command in plugin.yml
* @param commandExecutor Custom coded CommandExecutor class
@ -41,8 +36,15 @@ public abstract class Module{
protected void registerCommand(JavaPlugin plugin, TBMCCommandBase commandBase){
TBMCChatAPI.AddCommand(plugin, commandBase);
}
/**
* Registers a Listener to this plugin
* @param plugin Main plugin responsible for stuff
* @param label Name of the command in plugin.yml
* @param commandExecutor Custom coded CommandExecutor class
*/
protected Listener registerListener(JavaPlugin plugin, Listener listener){
TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin);
return listener;
}
}

View file

@ -10,7 +10,6 @@ public class FlairDoorModule extends Module {
@Override
public void register(JavaPlugin plugin) {
registerCommand(plugin, new FlairMe());
registerListener(plugin, new PortalListener(plugin));
}
}

View file

@ -9,9 +9,8 @@ public class FlairMe extends TBMCCommandBase {
@Override
public boolean OnCommand(CommandSender sender, String label, String[] args) {
sender.sendMessage("Flairing..." + sender.getName());
PortalListener.playersToBeFlaired.add(sender.getName());
sender.sendMessage("Finished Preparation! Walk through a portal to get your flair");
sender.sendMessage("Setup Successful! Walk through a portal to get your flair");
return false;
}

View file

@ -57,19 +57,15 @@ public class PortalListener implements Listener{
//RECOLOUR PLAYER
if(HigherBlock.getType() == Material.STONE){
player.sendMessage("STONE DETECTED");
recolourPlayer(player, DyeColor.GRAY);
//TOP BLOCK IS WOOL?
}else if(HigherBlock.getType() == Material.WOOL){
player.sendMessage("WOOL DETECTED T");
Wool wool = (Wool) HigherBlock.getState().getData();
recolourPlayer(player, wool.getColor());
//MIDDLE BLOCK IS WOOL?
}else if(MiddleBlock.getType() == Material.WOOL){
player.sendMessage("WOOL DETECTED M");
MaterialData mData = MiddleBlock.getState().getData();
Wool wool = (Wool) mData;
@ -77,7 +73,6 @@ public class PortalListener implements Listener{
//BOTTOM BLOCK IS WOOL?
}else if (BottomBlock.getType() == Material.WOOL){
player.sendMessage("WOOL DETECTED B");
Wool wool = (Wool) BottomBlock.getState().getData();
recolourPlayer(player, wool.getColor());
}
@ -86,60 +81,58 @@ public class PortalListener implements Listener{
public void recolourPlayer(Player player, DyeColor dyecolour){
User user = essentials.getUser(player);
player.sendMessage("Recolouring Player as..." + dyecolour.toString());
String name = user._getNickname();
player.sendMessage("name:" + name);
String tempName = "";
for(int i = 0; i < name.length(); i++){
player.sendMessage("|"+name.charAt(i)+"|");
if (name.charAt(i) != '§'){
tempName += name.charAt(i);
}else{
i++;
}
}
name = tempName;
player.sendMessage("Adjusted Name: " + name);
switch(dyecolour){
case GRAY:
player.sendMessage("Adding GRAY");
player.sendMessage("Adding §7GRAY!§f");
name = "§7" + name;
break;
case RED:
player.sendMessage("Adding RED");
player.sendMessage("Adding §4RED!§f");
name = "§4" + name;
break;
case ORANGE:
player.sendMessage("Adding ORANGE");
player.sendMessage("Adding §6ORANGE!§f");
name = "§6" + name;
break;
case YELLOW:
player.sendMessage("Adding YELLOW");
player.sendMessage("Adding §eYELLOW!§f");
name = "§e" + name;
break;
case LIME:
case GREEN:
player.sendMessage("Adding GREEN");
player.sendMessage("Adding §aGREEN!§f");
name = "§a" + name;
break;
case CYAN:
case LIGHT_BLUE:
case BLUE:
player.sendMessage("Adding BLUE");
player.sendMessage("Adding §9BLUE!§f");
name = "§9" + name;
break;
case PURPLE:
player.sendMessage("Adding PURPLE");
player.sendMessage("Adding §5PURPLE!§f");
name = "§5" + name;
break;
case WHITE:
player.sendMessage("Adding §fWHITE!§f");
name = "§f" + name;
default:
player.sendMessage("ERROR, PORTAL HAS INVALID UNDER-BLOCK");
break;
}
user.setNickname(name);
player.sendMessage("Your name is now: " + user.getNickname() +"! Removing you from playersToBeFlaired...");
player.sendMessage("Your name is now: " + user.getNickname() +"!");
playersToBeFlaired.remove(player.getName());
}
}

View file

@ -13,17 +13,22 @@ public class GPowerMemory{
poweredPlayerList.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
}
public void PowerUpPlayer(Player player){
player.sendMessage("Powering up!");
if(poweredPlayerList.containsKey(player.getUniqueId())){
poweredPlayerList.get(player.getUniqueId()).isPowersActive = true;
player.sendMessage("Powered up!");
}else{
player.sendMessage("You must instantiate your power settings using /GPower");
}
}
public void PowerDownPlayer(Player player){
player.sendMessage("Powering down!");
if (poweredPlayerList.containsKey(player.getUniqueId())){
player.sendMessage("Powered down!");
poweredPlayerList.get(player.getUniqueId()).isPowersActive = false;
}else{
player.sendMessage("P down!");
return;
}

View file

@ -18,6 +18,7 @@ public class PowerUp extends TBMCCommandBase {
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 a dev/ali if you think this is wrong");
Player player = (Player) sender;
gPowerMemory.PowerUpPlayer(player);
return false;

View file

@ -10,6 +10,8 @@ import alisolarflare.Module;
import alisolarflare.creativeboundaries.commands.Cbgm0;
import alisolarflare.creativeboundaries.commands.Cbgm1;
import alisolarflare.creativeboundaries.commands.SetDickmode;
import alisolarflare.creativeboundaries.listeners.ItemRestrictionListener;
import alisolarflare.creativeboundaries.listeners.PlotChangeListener;
public class CreativeBoundariesModule extends Module{
@ -21,8 +23,8 @@ public class CreativeBoundariesModule extends Module{
registerCommand(plugin, new Cbgm0(this));
registerCommand(plugin, new SetDickmode(this));
registerListener(plugin, new PlotChangeListener(this));
//registerListener(plugin, new ItemRestrictionListener(this));
}
}

View file

@ -0,0 +1,26 @@
package alisolarflare.creativeboundaries.listeners;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCreativeEvent;
import alisolarflare.creativeboundaries.CreativeBoundariesModule;
public class ItemRestrictionListener implements Listener {
private CreativeBoundariesModule module;
public ItemRestrictionListener(CreativeBoundariesModule module) {
this.module = module;
}
@EventHandler
public void onItemTake(InventoryCreativeEvent event){
List<Player> cbCreatives = module.cbCreatives;
}
}

View file

@ -1,4 +1,4 @@
package alisolarflare.creativeboundaries;
package alisolarflare.creativeboundaries.listeners;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
@ -12,6 +12,8 @@ import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownBlock;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import alisolarflare.creativeboundaries.CreativeBoundariesModule;
public class PlotChangeListener implements Listener{
public CreativeBoundariesModule module;
public PlotChangeListener(CreativeBoundariesModule module){

View file

@ -12,7 +12,7 @@ public class BoomBowDeathListener implements Listener{
if (player.getLastDamage() > 7.42420 && player.getLastDamage() < 7.42429){
player.sendMessage("42!");
event.setDeathMessage(player.getName() + "got trigger happy with the Boom Bow");
event.setDeathMessage(player.getName() + " got trigger happy with the [Boom Bow]");
}
}
}

View file

@ -3,6 +3,7 @@ package alisolarflare.uhc;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.Module;
import alisolarflare.uhc.controller.SetMatchState;
import alisolarflare.uhc.idle.AddToUHC;
import alisolarflare.uhc.idle.JoinUHC;
import alisolarflare.uhc.intro.ConfigureMatch;
@ -23,6 +24,8 @@ public class UHCModule extends Module {
match = new UHCMatch(plugin.getConfig(), MatchState.IDLE);
}
registerCommand(plugin, new SetMatchState(match));
registerCommand(plugin, new AddToUHC(match));
registerCommand(plugin, new JoinUHC(match));
registerCommand(plugin, new StartMatch(match));

View file

@ -0,0 +1,76 @@
package alisolarflare.uhc.controller;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.uhc.memory.MatchState;
import alisolarflare.uhc.memory.UHCMatch;
import buttondevteam.lib.chat.TBMCCommandBase;
public class SetMatchState extends TBMCCommandBase{
UHCMatch match;
public SetMatchState(UHCMatch match) {
this.match = match;
}
@Override
public String[] GetHelpText(String alias) {
return null;
}
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
return false;
}
Player player = (Player) sender;
if (player.getName().equalsIgnoreCase("alisolarflare") && player.getName().equalsIgnoreCase("Arsen_Derby_FTW")){
sender.sendMessage("You must be either Ali or Arsen to use this command!");
return false;
}
if(args.length < 1 ){
player.sendMessage("Usage: /setMatchState [stateToBeSet]");
player.sendMessage("States: IDLE, WAITING, SETUP, INTRO, PEACE, POWER, TENSION, END");
return false;
}
String inputState = args[0];
boolean inputIsValidState = false;
for (MatchState defaultMatchState : MatchState.values()){
if(inputState.equalsIgnoreCase(defaultMatchState.toString())){
inputIsValidState = true;
}
}
if (inputIsValidState){
match.setMatchState(MatchState.valueOf(inputState));
player.sendMessage("Match State set to: " + match.getMatchState().toString() + "!");
}else{
player.sendMessage("Error, could not parse state.");
player.sendMessage("Valid States: IDLE, WAITING, SETUP, INTRO, PEACE, POWER, TENSION, END");
return false;
}
return false;
}
@Override
public boolean GetPlayerOnly() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -0,0 +1,5 @@
package alisolarflare.uhc.intro;
public class IntroductionCutscene {
//TODO: Teleport all players to the area.
}

View file

@ -23,6 +23,10 @@ public class UHCMatch {
public void setMatchState(MatchState newMS){
matchState = newMS;
fileConfiguration.set("UHCMatchState", newMS.toString());
switch(newMS){
default:
break;
}
}
}