Merge pull request #20 from TBMCPlugins/Ali

Ali
This commit is contained in:
alisolarflare 2016-11-06 17:18:56 -05:00 committed by GitHub
commit 71458fb730
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 description: List all fighters currently in a button minigame
setcolourspawn: setcolourspawn:
description: sets the spawn points for each colour in a button minigame description: sets the spawn points for each colour in a button minigame
setmatchstate:
description: sets the current state of the ultrahardcore game.
addtouhc: addtouhc:
description: Adds a player to the UltraHardcore match description: Adds a player to the UltraHardcore match
joinuhc: joinuhc:

View file

@ -18,10 +18,10 @@ public class AliPresents extends JavaPlugin{
public void onEnable(){ public void onEnable(){
PluginDescriptionFile pdfFile = getDescription(); PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger(); Logger logger = getLogger();
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ")."); logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
new FlairDoorModule().register(this); new FlairDoorModule().register(this);
new GPowerModule().register(this); new GPowerModule().register(this);
new AliLinkModule().register(this); new AliLinkModule().register(this);
@ -30,6 +30,7 @@ public class AliPresents extends JavaPlugin{
new MinigameModule().register(this); new MinigameModule().register(this);
new CreativeBoundariesModule().register(this); new CreativeBoundariesModule().register(this);
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); 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; import buttondevteam.lib.chat.TBMCCommandBase;
/** /**
* A Module class is a helper class that allows the compacting of projects into one single package. * A Module class 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 * Each feature can have its commands and listeners coded into the Module class,
* classes in the package. * 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, * 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 * 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{ public abstract class Module{
/** /**
* Registers the project, when called by the Main JavaPlugin class that handles * Registers the module, when called by the JavaPlugin class. Call
* the main plugin. * 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 * @param plugin Plugin class called to register commands and listeners
*/ */
public abstract void register(JavaPlugin plugin); 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 plugin Main plugin responsible for stuff
* @param label Name of the command in plugin.yml * @param label Name of the command in plugin.yml
* @param commandExecutor Custom coded CommandExecutor class * @param commandExecutor Custom coded CommandExecutor class
@ -41,8 +36,15 @@ public abstract class Module{
protected void registerCommand(JavaPlugin plugin, TBMCCommandBase commandBase){ protected void registerCommand(JavaPlugin plugin, TBMCCommandBase commandBase){
TBMCChatAPI.AddCommand(plugin, 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){ protected Listener registerListener(JavaPlugin plugin, Listener listener){
TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin); TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin);
return listener; return listener;
} }
} }

View file

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

View file

@ -9,9 +9,8 @@ public class FlairMe extends TBMCCommandBase {
@Override @Override
public boolean OnCommand(CommandSender sender, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
sender.sendMessage("Flairing..." + sender.getName());
PortalListener.playersToBeFlaired.add(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; return false;
} }

View file

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

View file

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

View file

@ -18,6 +18,7 @@ public class PowerUp extends TBMCCommandBase {
public boolean OnCommand(CommandSender sender, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
if (!(sender instanceof Player)) 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"); 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; Player player = (Player) sender;
gPowerMemory.PowerUpPlayer(player); gPowerMemory.PowerUpPlayer(player);
return false; return false;

View file

@ -10,6 +10,8 @@ import alisolarflare.Module;
import alisolarflare.creativeboundaries.commands.Cbgm0; import alisolarflare.creativeboundaries.commands.Cbgm0;
import alisolarflare.creativeboundaries.commands.Cbgm1; import alisolarflare.creativeboundaries.commands.Cbgm1;
import alisolarflare.creativeboundaries.commands.SetDickmode; import alisolarflare.creativeboundaries.commands.SetDickmode;
import alisolarflare.creativeboundaries.listeners.ItemRestrictionListener;
import alisolarflare.creativeboundaries.listeners.PlotChangeListener;
public class CreativeBoundariesModule extends Module{ public class CreativeBoundariesModule extends Module{
@ -21,8 +23,8 @@ public class CreativeBoundariesModule extends Module{
registerCommand(plugin, new Cbgm0(this)); registerCommand(plugin, new Cbgm0(this));
registerCommand(plugin, new SetDickmode(this)); registerCommand(plugin, new SetDickmode(this));
registerListener(plugin, new PlotChangeListener(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.GameMode;
import org.bukkit.entity.Player; 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.TownBlock;
import com.palmergames.bukkit.towny.object.TownyUniverse; import com.palmergames.bukkit.towny.object.TownyUniverse;
import alisolarflare.creativeboundaries.CreativeBoundariesModule;
public class PlotChangeListener implements Listener{ public class PlotChangeListener implements Listener{
public CreativeBoundariesModule module; public CreativeBoundariesModule module;
public PlotChangeListener(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){ if (player.getLastDamage() > 7.42420 && player.getLastDamage() < 7.42429){
player.sendMessage("42!"); 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 org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.Module; import alisolarflare.Module;
import alisolarflare.uhc.controller.SetMatchState;
import alisolarflare.uhc.idle.AddToUHC; import alisolarflare.uhc.idle.AddToUHC;
import alisolarflare.uhc.idle.JoinUHC; import alisolarflare.uhc.idle.JoinUHC;
import alisolarflare.uhc.intro.ConfigureMatch; import alisolarflare.uhc.intro.ConfigureMatch;
@ -23,6 +24,8 @@ public class UHCModule extends Module {
match = new UHCMatch(plugin.getConfig(), MatchState.IDLE); match = new UHCMatch(plugin.getConfig(), MatchState.IDLE);
} }
registerCommand(plugin, new SetMatchState(match));
registerCommand(plugin, new AddToUHC(match)); registerCommand(plugin, new AddToUHC(match));
registerCommand(plugin, new JoinUHC(match)); registerCommand(plugin, new JoinUHC(match));
registerCommand(plugin, new StartMatch(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){ public void setMatchState(MatchState newMS){
matchState = newMS; matchState = newMS;
fileConfiguration.set("UHCMatchState", newMS.toString()); fileConfiguration.set("UHCMatchState", newMS.toString());
switch(newMS){
default:
break;
}
} }
} }