Added code for exception handling

And other stuff :P
This commit is contained in:
Norbi Peti 2016-11-03 01:22:51 +01:00
parent 0d3c83b65f
commit 20e8ce27b8
20 changed files with 483 additions and 268 deletions

View file

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.github.tbmcplugins</groupId> <groupId>com.github.tbmcplugins</groupId>
<artifactId>AliPresents</artifactId> <artifactId>AliPresents</artifactId>
@ -63,5 +64,10 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.4</version> <version>3.4</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
<artifactId>ButtonCore</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -1,9 +1,11 @@
package alisolarflare.modules; package alisolarflare.modules;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
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. * 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 * Each feature, whether game, arrow trail listener, or command tool, can have its command and listener
@ -35,9 +37,8 @@ public abstract class Module implements Registerable{
* @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
*/ */
protected CommandExecutor registerCommand(JavaPlugin plugin, String label, CommandExecutor commandExecutor){ protected <T extends TBMCCommandBase> void registerCommand(JavaPlugin plugin, String label, Class<T> commandExecutor){
plugin.getCommand(label).setExecutor(commandExecutor); TBMCChatAPI.AddCommands(plugin, commandExecutor);
return commandExecutor;
} }
protected Listener registerListener(JavaPlugin plugin, Listener listener){ protected Listener registerListener(JavaPlugin plugin, Listener listener){
plugin.getServer().getPluginManager().registerEvents(listener, plugin); plugin.getServer().getPluginManager().registerEvents(listener, plugin);

View file

@ -6,13 +6,14 @@ import alisolarflare.modules.Module;
import alisolarflare.modules.components.flairdoor.commands.FlairMe; import alisolarflare.modules.components.flairdoor.commands.FlairMe;
import alisolarflare.modules.components.flairdoor.commands.SetFlairDoorColour; import alisolarflare.modules.components.flairdoor.commands.SetFlairDoorColour;
import alisolarflare.modules.components.flairdoor.listeners.PortalListener; import alisolarflare.modules.components.flairdoor.listeners.PortalListener;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.TBMCChatAPI;
public class FlairDoorModule extends Module { public class FlairDoorModule extends Module {
@Override @Override
public void register(JavaPlugin plugin) { public void register(JavaPlugin plugin) {
plugin.getCommand("flairme").setExecutor(new FlairMe()); TBMCChatAPI.AddCommands(plugin, FlairMe.class);
plugin.getCommand("setflairdoorcolour").setExecutor(new SetFlairDoorColour());
plugin.getServer().getPluginManager().registerEvents(new PortalListener(plugin), plugin); TBMCCoreAPI.RegisterEventsForExceptions(new PortalListener(plugin), plugin);
} }
} }

View file

@ -1,15 +1,14 @@
package alisolarflare.modules.components.flairdoor.commands; package alisolarflare.modules.components.flairdoor.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import alisolarflare.modules.components.flairdoor.listeners.PortalListener; import alisolarflare.modules.components.flairdoor.listeners.PortalListener;
import buttondevteam.lib.chat.TBMCCommandBase;
public class FlairMe implements CommandExecutor{ public class FlairMe extends TBMCCommandBase {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
sender.sendMessage("Flairing..." + sender.getName()); 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("Finished Preparation! Walk through a portal to get your flair");
@ -17,4 +16,25 @@ public class FlairMe implements CommandExecutor{
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return new String[] { "" };
}
@Override
public String GetCommandPath() {
return "flairme";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
return false;
}
} }

View file

@ -3,15 +3,17 @@ package alisolarflare.modules.components.flairdoor.commands;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class SetFlairDoorColour implements CommandExecutor { import buttondevteam.lib.chat.TBMCCommandBase;
public class SetFlairDoorColour extends TBMCCommandBase {
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"); 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, String label, String[] args) {
if (args.length > 1) { if (args.length > 1) {
sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA"); sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA");
} }
@ -45,4 +47,24 @@ public class SetFlairDoorColour implements CommandExecutor {
} }
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) { // TODO
return new String[] { "" };
}
@Override
public String GetCommandPath() {
return "setflairdoorcolour";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
return false;
}
} }

View file

@ -7,16 +7,16 @@ import alisolarflare.modules.components.gpowers.commands.PowerDown;
import alisolarflare.modules.components.gpowers.commands.PowerUp; import alisolarflare.modules.components.gpowers.commands.PowerUp;
import alisolarflare.modules.components.gpowers.commands.gPowerCommand; import alisolarflare.modules.components.gpowers.commands.gPowerCommand;
import alisolarflare.modules.components.gpowers.listeners.gPowerListener; import alisolarflare.modules.components.gpowers.listeners.gPowerListener;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.TBMCChatAPI;
public class GPowerModule extends Module { public class GPowerModule extends Module {
@Override @Override
public void register(JavaPlugin plugin) { public void register(JavaPlugin plugin) {
plugin.getCommand("powerup").setExecutor(new PowerUp()); TBMCChatAPI.AddCommands(plugin, gPowerCommand.class);
plugin.getCommand("powerdown").setExecutor(new PowerDown());
plugin.getCommand("gpowercommand").setExecutor(new gPowerCommand());
plugin.getServer().getPluginManager().registerEvents(new gPowerListener(plugin), plugin); TBMCCoreAPI.RegisterEventsForExceptions(new gPowerListener(plugin), plugin);
} }
} }

View file

@ -4,10 +4,35 @@ 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 PowerDown implements CommandExecutor { import buttondevteam.lib.chat.TBMCCommandBase;
public class PowerDown extends TBMCCommandBase {
@Override @Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) { public boolean OnCommand(CommandSender arg0, String arg2, String[] arg3) {
// TODO Auto-generated method stub
return false;
}
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public String GetCommandPath() {
return "powerdown";
}
@Override
public boolean GetPlayerOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }

View file

@ -5,16 +5,36 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import buttondevteam.lib.chat.TBMCCommandBase;
public class PowerUp implements CommandExecutor{ public class PowerUp extends TBMCCommandBase {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
}
// gPowerMemory.PowerUpPlayer(player, colour); // gPowerMemory.PowerUpPlayer(player, colour);
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public String GetCommandPath() {
return "powerup";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -6,16 +6,13 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import alisolarflare.modules.components.gpowers.gPowerMemory; import alisolarflare.modules.components.gpowers.gPowerMemory;
import buttondevteam.lib.chat.TBMCCommandBase;
public class gPowerCommand implements CommandExecutor{ public class gPowerCommand extends TBMCCommandBase {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
sender.sendMessage("G power activate!"); sender.sendMessage("G power activate!");
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
return false;
}
Player player = (Player) sender; Player player = (Player) sender;
if (args.length < 2) { if (args.length < 2) {
player.sendMessage("Proper Usage to test G-Powers:"); player.sendMessage("Proper Usage to test G-Powers:");
@ -24,12 +21,8 @@ public class gPowerCommand implements CommandExecutor{
} }
String colour; String colour;
player.sendMessage("Checking terms..."); player.sendMessage("Checking terms...");
if(args[0].startsWith("r") || if (args[0].startsWith("r") || args[0].startsWith("o") || args[0].startsWith("y") || args[0].startsWith("g")
args[0].startsWith("o")|| || args[0].startsWith("b") || args[0].startsWith("p")) {
args[0].startsWith("y")||
args[0].startsWith("g")||
args[0].startsWith("b")||
args[0].startsWith("p")){
colour = args[0]; colour = args[0];
} else { } else {
player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:"); player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:");
@ -55,4 +48,25 @@ public class gPowerCommand implements CommandExecutor{
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return new String[] { "" };
}
@Override
public String GetCommandPath() {
return "gpower";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
return false;
}
} }

View file

@ -1,4 +1,5 @@
package alisolarflare.modules.components.links; package alisolarflare.modules.components.links;
import java.util.List; import java.util.List;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -7,6 +8,7 @@ import alisolarflare.modules.Module;
import alisolarflare.modules.components.links.commands.PressAliLink; import alisolarflare.modules.components.links.commands.PressAliLink;
import alisolarflare.modules.components.links.commands.SetAliLink; import alisolarflare.modules.components.links.commands.SetAliLink;
import alisolarflare.modules.components.links.entities.Link; import alisolarflare.modules.components.links.entities.Link;
import buttondevteam.lib.chat.TBMCChatAPI;
public class AliLinkModule extends Module { public class AliLinkModule extends Module {
private SetAliLink setAliLink; private SetAliLink setAliLink;
@ -14,10 +16,10 @@ public class AliLinkModule extends Module{
@Override @Override
public void register(JavaPlugin plugin) { public void register(JavaPlugin plugin) {
setAliLink = new SetAliLink(plugin); setAliLink = new SetAliLink(plugin);
plugin.getCommand("setalilink").setExecutor(setAliLink); TBMCChatAPI.AddCommands(plugin, PressAliLink.class);
plugin.getCommand("pressalilink").setExecutor(new PressAliLink(plugin, setAliLink));
} }
public void saveLinkList(JavaPlugin plugin) { public void saveLinkList(JavaPlugin plugin) {
plugin.getConfig().set("aliLinkList", setAliLink.linkList); plugin.getConfig().set("aliLinkList", setAliLink.linkList);
} }
@ -27,5 +29,4 @@ public class AliLinkModule extends Module{
return (List<Link>) plugin.getConfig().getList("aliLinkList"); return (List<Link>) plugin.getConfig().getList("aliLinkList");
} }
} }

View file

@ -6,16 +6,19 @@ import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.modules.components.links.entities.Link; import alisolarflare.modules.components.links.entities.Link;
import buttondevteam.lib.chat.TBMCCommandBase;
public class PressAliLink implements CommandExecutor{ public class PressAliLink extends TBMCCommandBase {
private JavaPlugin plugin; private JavaPlugin plugin;
private SetAliLink setAliLink; private SetAliLink setAliLink;
public PressAliLink(JavaPlugin plugin, SetAliLink setAliLink) { public PressAliLink(JavaPlugin plugin, SetAliLink setAliLink) {
this.plugin = plugin; this.plugin = plugin;
this.setAliLink = setAliLink; this.setAliLink = setAliLink;
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
sender.getServer().broadcastMessage(setAliLink.linkList.toString() + "over."); sender.getServer().broadcastMessage(setAliLink.linkList.toString() + "over.");
@ -33,4 +36,27 @@ public class PressAliLink implements CommandExecutor{
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public String GetCommandPath() {
return "pressalilink";
}
@Override
public boolean GetPlayerOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -1,6 +1,5 @@
package alisolarflare.modules.components.links.commands; package alisolarflare.modules.components.links.commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -14,52 +13,54 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.modules.components.links.AliLinkModule; import alisolarflare.modules.components.links.AliLinkModule;
import alisolarflare.modules.components.links.entities.Link; import alisolarflare.modules.components.links.entities.Link;
import buttondevteam.lib.chat.TBMCCommandBase;
/** /**
* This class manages the command /SetAliLink <frequency> [x] [y] [z]. This command creates an Ali-Link, * This class manages the command /SetAliLink <frequency> [x] [y] [z]. This command creates an Ali-Link, a location in a world that when called on by {@link PressAliLink}, creates a temporary redstone
* a location in a world that when called on by {@link Class#PressAliLink}, creates a temporary redstone block, * block, enabling wireless redstone
* enabling wireless redstone
* *
* @see Class#PressAliLink * @see PressAliLink
* @author Alisolarflare * @author Alisolarflare
* *
*/ */
public class SetAliLink implements CommandExecutor{ public class SetAliLink extends TBMCCommandBase {
public List<Link> linkList = new ArrayList<Link>(); public List<Link> linkList = new ArrayList<Link>();
AliLinkModule subplugin; AliLinkModule subplugin;
private JavaPlugin plugin; private JavaPlugin plugin;
/** /**
* Constructs the SetAliLink class * Constructs the SetAliLink class
* @param plugin The plugin that contains the configuration file of SetAliLink *
* @param plugin
* The plugin that contains the configuration file of SetAliLink
*/ */
public SetAliLink(JavaPlugin plugin) { public SetAliLink(JavaPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
load(); load();
} }
/** /**
* This command creates an Ali-Link which, when activated by the command /PressAliLink, * This command creates an Ali-Link which, when activated by the command /PressAliLink, creates a temporary redstone block if and only if /PressAliLink [frequency] matches the frequency saved when
* creates a temporary redstone block if and only if /PressAliLink [frequency] matches the frequency * /SetAliLink [frequency] is called.
* saved when /SetAliLink [frequency] is called.
* *
* @see Class#PressAliLink * @see Class#PressAliLink
* @param sender Player who sent the command * @param sender
* @param command Command Object created * Player who sent the command
* @param label Name of the command * @param command
* @param args Arguments: [frequency] [x-coordinate] [y-coordinate] [z-coordinate], where the coordinates point * Command Object created
* to the intended location of the Ali-Link * @param label
* Name of the command
* @param args
* Arguments: [frequency] [x-coordinate] [y-coordinate] [z-coordinate], where the coordinates point to the intended location of the Ali-Link
*/ */
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
sender.sendMessage("you pressed shit"); sender.sendMessage("you pressed shit");
if (args == null || args.length < 1) { if (args == null || args.length < 1) {
sender.sendMessage("You must specify a link frequency"); sender.sendMessage("You must specify a link frequency");
sender.sendMessage("/pressalilink [name]"); sender.sendMessage("/pressalilink [name]");
return false; return false;
} }
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
}
Player player = (Player) sender; Player player = (Player) sender;
if (args.length < 4) { if (args.length < 4) {
player.sendMessage("short"); player.sendMessage("short");
@ -68,9 +69,11 @@ public class SetAliLink implements CommandExecutor{
player.sendMessage("end"); player.sendMessage("end");
return false; return false;
} }
if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2]) && StringUtils.isNumericSpace(args[3])){ if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2])
&& StringUtils.isNumericSpace(args[3])) {
player.sendMessage("CUUUSTOM"); player.sendMessage("CUUUSTOM");
linkList.add(new Link(args[0],new Location(player.getWorld(), Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3])))); linkList.add(new Link(args[0], new Location(player.getWorld(), Double.parseDouble(args[1]),
Double.parseDouble(args[2]), Double.parseDouble(args[3]))));
save(player); save(player);
player.sendMessage("FINISHED"); player.sendMessage("FINISHED");
} else { } else {
@ -82,9 +85,10 @@ public class SetAliLink implements CommandExecutor{
} }
return false; return false;
} }
/** /**
* Tries to save the entire SetAliLink class into memory, which includes * Tries to save the entire SetAliLink class into memory, which includes all of the current Ali-links saved and in use.
* all of the current Ali-links saved and in use. *
* @param player * @param player
*/ */
private void save(Player player) { private void save(Player player) {
@ -93,21 +97,13 @@ public class SetAliLink implements CommandExecutor{
player.sendMessage("Link will only last until next server restart"); player.sendMessage("Link will only last until next server restart");
return; return;
/* /*
subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList); * subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList); try { player.sendMessage("SAVIN"); subplugin.plugin.saveConfig(); player.sendMessage("GOOD SAVE"); } catch (Exception e)
try { * { player.sendMessage("YOU FUCKED STUFF UP"); // TODO Auto-generated catch block e.printStackTrace(); }
player.sendMessage("SAVIN");
subplugin.plugin.saveConfig();
player.sendMessage("GOOD SAVE");
} catch (Exception e) {
player.sendMessage("YOU FUCKED STUFF UP");
// TODO Auto-generated catch block
e.printStackTrace();
}
*/ */
} }
/** /**
* Attempts to load the previous saved state of AliLinks, from the plugin * Attempts to load the previous saved state of AliLinks, from the plugin configuration file
* configuration file
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void load() { private void load() {
@ -121,4 +117,26 @@ public class SetAliLink implements CommandExecutor{
} }
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public String GetCommandPath() {
return "setalilink";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -4,12 +4,13 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.modules.Module; import alisolarflare.modules.Module;
import alisolarflare.modules.components.shulker.commands.AliShulker; import alisolarflare.modules.components.shulker.commands.AliShulker;
import buttondevteam.lib.chat.TBMCChatAPI;
public class AliShulkerModule extends Module { public class AliShulkerModule extends Module {
@Override @Override
public void register(JavaPlugin plugin) { public void register(JavaPlugin plugin) {
plugin.getCommand("alishulker").setExecutor(new AliShulker()); TBMCChatAPI.AddCommands(plugin, AliShulker.class);
} }
} }

View file

@ -10,23 +10,17 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker; import org.bukkit.entity.Shulker;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import buttondevteam.lib.chat.TBMCCommandBase;
/** /**
* @author Alisolarflare * @author Alisolarflare This class is responsible for the command /aliShulker, which in-game spawns a shulker that: Has a health of 10 Has a wither and invisibility effect present Has noAI And is
* This class is responsible for the command /aliShulker, which in-game spawns * Glowing
* a shulker that:
* Has a health of 10
* Has a wither and invisibility effect present
* Has noAI
* And is Glowing
*/ */
public class AliShulker implements CommandExecutor { public class AliShulker extends TBMCCommandBase {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
return false;
}
Player player = (Player) sender; Player player = (Player) sender;
if (!(player.getName().equals("iie") || player.getName().equals("alisolarflare"))) { if (!(player.getName().equals("iie") || player.getName().equals("alisolarflare"))) {
return false; return false;
@ -44,4 +38,26 @@ public class AliShulker implements CommandExecutor {
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public String GetCommandPath() {
return "alishulker";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -6,6 +6,7 @@ import alisolarflare.modules.Module;
import alisolarflare.modules.events.uhc.commands.AddToUHC; import alisolarflare.modules.events.uhc.commands.AddToUHC;
import alisolarflare.modules.events.uhc.commands.StartMatch; import alisolarflare.modules.events.uhc.commands.StartMatch;
import alisolarflare.modules.events.uhc.memory.UHCMatch; import alisolarflare.modules.events.uhc.memory.UHCMatch;
import buttondevteam.lib.chat.TBMCChatAPI;
public class UHCModule extends Module { public class UHCModule extends Module {
public UHCMatch match; public UHCMatch match;
@ -15,12 +16,14 @@ public class UHCModule extends Module {
registerListeners(plugin); registerListeners(plugin);
registerMemoryUnits(plugin); registerMemoryUnits(plugin);
} }
private void registerListeners(JavaPlugin plugin) { private void registerListeners(JavaPlugin plugin) {
} }
private void registerCommands(JavaPlugin plugin) { private void registerCommands(JavaPlugin plugin) {
registerCommand(plugin, "addToUHC", new AddToUHC(this.match)); TBMCChatAPI.AddCommands(plugin, AddToUHC.class);
registerCommand(plugin, "startMatch", new StartMatch(this.match));
} }
private void registerMemoryUnits(JavaPlugin plugin) { private void registerMemoryUnits(JavaPlugin plugin) {
match = new UHCMatch(plugin.getConfig(), plugin.getConfig().getString("UHCMatchState")); match = new UHCMatch(plugin.getConfig(), plugin.getConfig().getString("UHCMatchState"));
} }

View file

@ -1,25 +1,24 @@
package alisolarflare.modules.events.uhc.commands; package alisolarflare.modules.events.uhc.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import alisolarflare.modules.events.uhc.memory.UHCMatch; import alisolarflare.modules.events.uhc.memory.UHCMatch;
import buttondevteam.lib.chat.TBMCCommandBase;
/** /**
* This class handles the specific command /addToUHC which, in-game, * This class handles the specific command /addToUHC which, in-game, adds a player to a specific UltraHardcore match, that is defined by the constructor: {@linkplain #AddToUHC(UHCMatch)}
* adds a player to a specific UltraHardcore match, that is defined *
* by the constructor: {@linkplain #AddToUHC(UHCMatch)}
* @author Alisolarflare * @author Alisolarflare
*/ */
public class AddToUHC implements CommandExecutor{ public class AddToUHC extends TBMCCommandBase {
private UHCMatch generalMemory; private UHCMatch generalMemory;
/** /**
* Constructor for this AddToUHC * Constructor for this AddToUHC
* @param generalMemory The Memory Unit for the current match *
* @param generalMemory
* The Memory Unit for the current match
*/ */
public AddToUHC(UHCMatch generalMemory) { public AddToUHC(UHCMatch generalMemory) {
this.generalMemory = generalMemory; this.generalMemory = generalMemory;
@ -27,18 +26,19 @@ public class AddToUHC implements CommandExecutor{
/** /**
* Activated function when /addtoUHC <> is typed in-game * Activated function when /addtoUHC <> is typed in-game
* @param sender CommandSender which sent the command /addToUHC *
* @param command Command object created when /addToUHC is called in-game * @param sender
* @param label Name of the command called * CommandSender which sent the command /addToUHC
* @param args Arguments passed onto /addToUHC by the player * @param command
* Command object created when /addToUHC is called in-game
* @param label
* Name of the command called
* @param args
* Arguments passed onto /addToUHC by the player
*/ */
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
// INPUT SANITATION // INPUT SANITATION
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
return false;
}
Player player = (Player) sender; Player player = (Player) sender;
if (player.getName() != "alisolarflare") { if (player.getName() != "alisolarflare") {
sender.sendMessage("You must be Ali to use this command, send her a message to change the permissions"); sender.sendMessage("You must be Ali to use this command, send her a message to change the permissions");
@ -55,4 +55,26 @@ public class AddToUHC implements CommandExecutor{
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public String GetCommandPath() {
return "addtouhc";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -7,17 +7,17 @@ import org.bukkit.entity.Player;
import alisolarflare.modules.events.uhc.memory.MatchState; import alisolarflare.modules.events.uhc.memory.MatchState;
import alisolarflare.modules.events.uhc.memory.UHCMatch; import alisolarflare.modules.events.uhc.memory.UHCMatch;
import buttondevteam.lib.chat.TBMCCommandBase;
public class StartMatch implements CommandExecutor { public class StartMatch extends TBMCCommandBase {
private UHCMatch match; private UHCMatch match;
public StartMatch(UHCMatch match) { public StartMatch(UHCMatch match) {
this.match = match; this.match = match;
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { 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 if you think this is wrong");
}
if (match.getMatchState() == MatchState.NULL) if (match.getMatchState() == MatchState.NULL)
sender.sendMessage("There is no match to begin."); sender.sendMessage("There is no match to begin.");
else if (match.getMatchState() == MatchState.IDLE) else if (match.getMatchState() == MatchState.IDLE)
@ -32,4 +32,26 @@ public class StartMatch implements CommandExecutor {
return false; return false;
} }
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public String GetCommandPath() {
return "startmatch";
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -15,7 +15,6 @@ public class AliArrowListener implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){ public void onProjectileLaunch(ProjectileLaunchEvent event){
try{ try{

View file

@ -1,8 +1,8 @@
package alisolarflare.modules.magictrick.aliarrow; package alisolarflare.modules.magictrick.aliarrow;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.modules.Module; import alisolarflare.modules.Module;
import buttondevteam.lib.TBMCCoreAPI;
public class AliArrowModule extends Module { public class AliArrowModule extends Module {
/** /**
@ -10,7 +10,7 @@ public class AliArrowModule extends Module{
*/ */
@Override @Override
public void register(JavaPlugin plugin) { public void register(JavaPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin); TBMCCoreAPI.RegisterEventsForExceptions(new AliArrowListener(plugin), plugin);
} }
} }

View file

@ -10,8 +10,6 @@ public class AliArrowTask extends BukkitRunnable{
String name; String name;
Arrow arrow; Arrow arrow;
public AliArrowTask(JavaPlugin plugin, Arrow arrow, String name) { public AliArrowTask(JavaPlugin plugin, Arrow arrow, String name) {
this.name = name; this.name = name;
this.plugin = plugin; this.plugin = plugin;
@ -31,8 +29,8 @@ public class AliArrowTask extends BukkitRunnable{
arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1); arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1);
} }
if (name.equals("NorbiPeti"))
arrow.getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1);
} }