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

134
pom.xml
View file

@ -1,67 +1,73 @@
<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>
<groupId>com.github.tbmcplugins</groupId>
<artifactId>AliPresents</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AliPresents</name>
<description>A bucket of aaall the stuff Ali makes. It's a bit smelly.</description>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>.</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<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>
<groupId>com.github.tbmcplugins</groupId>
<artifactId>AliPresents</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AliPresents</name>
<description>A bucket of aaall the stuff Ali makes. It's a bit smelly.</description>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>.</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository> <!-- This repo fixes issues with transitive dependencies -->
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository> <!-- This repo fixes issues with transitive dependencies -->
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.9.2-R0.1-SNAPSHOT</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.9.2-R0.1-SNAPSHOT</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
<artifactId>ButtonCore</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View file

@ -1,9 +1,11 @@
package alisolarflare.modules;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
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.
* 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 commandExecutor Custom coded CommandExecutor class
*/
protected CommandExecutor registerCommand(JavaPlugin plugin, String label, CommandExecutor commandExecutor){
plugin.getCommand(label).setExecutor(commandExecutor);
return commandExecutor;
protected <T extends TBMCCommandBase> void registerCommand(JavaPlugin plugin, String label, Class<T> commandExecutor){
TBMCChatAPI.AddCommands(plugin, commandExecutor);
}
protected Listener registerListener(JavaPlugin plugin, Listener listener){
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.SetFlairDoorColour;
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
public void register(JavaPlugin plugin) {
plugin.getCommand("flairme").setExecutor(new FlairMe());
plugin.getCommand("setflairdoorcolour").setExecutor(new SetFlairDoorColour());
TBMCChatAPI.AddCommands(plugin, FlairMe.class);
plugin.getServer().getPluginManager().registerEvents(new PortalListener(plugin), plugin);
TBMCCoreAPI.RegisterEventsForExceptions(new PortalListener(plugin), plugin);
}
}

View file

@ -1,19 +1,39 @@
package alisolarflare.modules.components.flairdoor.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import alisolarflare.modules.components.flairdoor.listeners.PortalListener;
import buttondevteam.lib.chat.TBMCCommandBase;
public class FlairMe implements CommandExecutor{
public class FlairMe extends TBMCCommandBase {
@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());
PortalListener.playersToBeFlaired.add(sender.getName());
sender.sendMessage("Finished Preparation! Walk through a portal to get your flair");
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,46 +3,68 @@ package alisolarflare.modules.components.flairdoor.commands;
import java.util.Arrays;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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 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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 1){
public boolean OnCommand(CommandSender sender, String label, String[] args) {
if (args.length > 1) {
sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA");
}
String firstCommand = args[0];
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 gray");
FlairDoorColorMode = "gray";
}else if(firstCommand.startsWith("r")){
} else if (firstCommand.startsWith("r")) {
sender.sendMessage("Flair Door Colour Mode set to Red");
FlairDoorColorMode = "red";
}else if(firstCommand.startsWith("o")){
} else if (firstCommand.startsWith("o")) {
sender.sendMessage("Flair Door Colour Mode set to Orange");
FlairDoorColorMode = "orange";
}else if(firstCommand.startsWith("y")){
} else if (firstCommand.startsWith("y")) {
sender.sendMessage("Flair Door Colour Mode set to Yellow");
FlairDoorColorMode = "yellow";
}else if(firstCommand.startsWith("g")){
} else if (firstCommand.startsWith("g")) {
sender.sendMessage("Flair Door Colour Mode set to Green (use E for grey)");
FlairDoorColorMode = "green";
}else if(firstCommand.startsWith("b") || firstCommand.startsWith("i")){
} else if (firstCommand.startsWith("b") || firstCommand.startsWith("i")) {
sender.sendMessage("Flair Door Colour Mode set to Blue");
FlairDoorColorMode = "blue";
}else if(firstCommand.startsWith("v") || firstCommand.startsWith("p")){
} else if (firstCommand.startsWith("v") || firstCommand.startsWith("p")) {
sender.sendMessage("Flair Door Colour Mode set to Purple");
FlairDoorColorMode = "purple";
}else if(firstCommand.startsWith("n")){
} else if (firstCommand.startsWith("n")) {
sender.sendMessage("Flair Door Colour Mode set to Null");
FlairDoorColorMode = "null";
}
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.gPowerCommand;
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
public void register(JavaPlugin plugin) {
plugin.getCommand("powerup").setExecutor(new PowerUp());
plugin.getCommand("powerdown").setExecutor(new PowerDown());
plugin.getCommand("gpowercommand").setExecutor(new gPowerCommand());
plugin.getServer().getPluginManager().registerEvents(new gPowerListener(plugin), plugin);
TBMCChatAPI.AddCommands(plugin, gPowerCommand.class);
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.CommandSender;
public class PowerDown implements CommandExecutor {
import buttondevteam.lib.chat.TBMCCommandBase;
public class PowerDown extends TBMCCommandBase {
@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
return false;
}

View file

@ -5,15 +5,35 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.lib.chat.TBMCCommandBase;
public class PowerUp implements CommandExecutor{
public class PowerUp extends TBMCCommandBase {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
}
//gPowerMemory.PowerUpPlayer(player, colour);
public boolean OnCommand(CommandSender sender, String label, String[] args) {
// gPowerMemory.PowerUpPlayer(player, colour);
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,53 +6,67 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.modules.components.gpowers.gPowerMemory;
import buttondevteam.lib.chat.TBMCCommandBase;
public class gPowerCommand implements CommandExecutor{
public class gPowerCommand extends TBMCCommandBase {
@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!");
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
return false;
}
Player player = (Player) sender;
if (args.length < 2){
if (args.length < 2) {
player.sendMessage("Proper Usage to test G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]");
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")){
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{
} 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]");
return false;
}
boolean isActive;
if(args[1].startsWith("t")){
if (args[1].startsWith("t")) {
isActive = true;
}else if (args[1].startsWith("f")){
} else if (args[1].startsWith("f")) {
isActive = false;
}else{
} else {
player.sendMessage("Term Fail: ACTIVE. Proper Usage to test G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]");
return false;
}
player.sendMessage("Terms Vaild!");
if(isActive){
if (isActive) {
gPowerMemory.PowerUpPlayer(player, colour);
}else{
} else {
gPowerMemory.PowerDownPlayer(player);
}
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;
import java.util.List;
import org.bukkit.plugin.java.JavaPlugin;
@ -7,25 +8,25 @@ import alisolarflare.modules.Module;
import alisolarflare.modules.components.links.commands.PressAliLink;
import alisolarflare.modules.components.links.commands.SetAliLink;
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;
@Override
public void register(JavaPlugin plugin){
public void register(JavaPlugin plugin) {
setAliLink = new SetAliLink(plugin);
plugin.getCommand("setalilink").setExecutor(setAliLink);
plugin.getCommand("pressalilink").setExecutor(new PressAliLink(plugin, setAliLink));
TBMCChatAPI.AddCommands(plugin, PressAliLink.class);
}
public void saveLinkList(JavaPlugin plugin){
public void saveLinkList(JavaPlugin plugin) {
plugin.getConfig().set("aliLinkList", setAliLink.linkList);
}
@SuppressWarnings("unchecked")
public List<Link> loadLinkList(JavaPlugin plugin){
public List<Link> loadLinkList(JavaPlugin plugin) {
return (List<Link>) plugin.getConfig().getList("aliLinkList");
}
}

View file

@ -6,26 +6,29 @@ import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
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 SetAliLink setAliLink;
public PressAliLink(JavaPlugin plugin, SetAliLink setAliLink){
public PressAliLink(JavaPlugin plugin, SetAliLink setAliLink) {
this.plugin = plugin;
this.setAliLink = setAliLink;
this.setAliLink = setAliLink;
}
@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.");
if (args.length < 1){
if (args.length < 1) {
sender.sendMessage("You must specify a link frequency");
sender.sendMessage("/pressalilink [frequency]");
}
for (Link link: setAliLink.linkList){
for (String inputlink: args){
if(inputlink.equals(link.frequency)){
for (Link link : setAliLink.linkList) {
for (String inputlink : args) {
if (inputlink.equals(link.frequency)) {
link.press(plugin);
}
}
@ -33,4 +36,27 @@ public class PressAliLink implements CommandExecutor{
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;
import java.util.ArrayList;
import java.util.List;
@ -14,66 +13,70 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.modules.components.links.AliLinkModule;
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,
* a location in a world that when called on by {@link Class#PressAliLink}, creates a temporary redstone block,
* enabling wireless redstone
* 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
* block, enabling wireless redstone
*
* @see Class#PressAliLink
* @see PressAliLink
* @author Alisolarflare
*
*/
public class SetAliLink implements CommandExecutor{
public class SetAliLink extends TBMCCommandBase {
public List<Link> linkList = new ArrayList<Link>();
AliLinkModule subplugin;
private JavaPlugin plugin;
/**
* 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;
load();
}
/**
* 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 /SetAliLink [frequency] is called.
* 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
* /SetAliLink [frequency] is called.
*
* @see Class#PressAliLink
* @param sender Player who sent the command
* @param command Command Object created
* @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
* @param sender
* Player who sent the command
* @param command
* Command Object created
* @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
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");
if (args == null || args.length < 1){
if (args == null || args.length < 1) {
sender.sendMessage("You must specify a link frequency");
sender.sendMessage("/pressalilink [name]");
return false;
}
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
}
Player player = (Player) sender;
if (args.length < 4){
if (args.length < 4) {
player.sendMessage("short");
linkList.add(new Link(args[0], player.getLocation()));
save(player);
player.sendMessage("end");
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");
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);
player.sendMessage("FINISHED");
}else{
} else {
player.sendMessage("UNCUSTOOM");
linkList.add(new Link(args[0], player.getLocation()));
save(player);
@ -82,43 +85,58 @@ public class SetAliLink implements CommandExecutor{
}
return false;
}
/**
* Tries to save the entire SetAliLink class into memory, which includes
* all of the current Ali-links saved and in use.
* Tries to save the entire SetAliLink class into memory, which includes all of the current Ali-links saved and in use.
*
* @param player
*/
private void save(Player player){
private void save(Player player) {
player.sendMessage("SAAAVING");
player.sendMessage("SAVE FAILED: TELL ALI TO FIX THE SAVE AND UN-COMMENT THE PARAGRAPH SHE COMMENTED");
player.sendMessage("Link will only last until next server restart");
return;
/*
subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList);
try {
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();
}
*/
* subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList); try { 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
* configuration file
* Attempts to load the previous saved state of AliLinks, from the plugin configuration file
*/
@SuppressWarnings("unchecked")
private void load(){
try{
private void load() {
try {
linkList = (List<Link>) plugin.getConfig().getList("aliLinkList");
if(linkList == null || linkList.isEmpty()){
if (linkList == null || linkList.isEmpty()) {
linkList = new ArrayList<Link>();
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
@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.components.shulker.commands.AliShulker;
import buttondevteam.lib.chat.TBMCChatAPI;
public class AliShulkerModule extends Module{
public class AliShulkerModule extends Module {
@Override
public void register(JavaPlugin plugin) {
plugin.getCommand("alishulker").setExecutor(new AliShulker());
TBMCChatAPI.AddCommands(plugin, AliShulker.class);
}
}

View file

@ -10,37 +10,53 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import buttondevteam.lib.chat.TBMCCommandBase;
/**
* @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 Glowing
* @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
* Glowing
*/
public class AliShulker implements CommandExecutor {
public class AliShulker extends TBMCCommandBase {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
return false;
}
public boolean OnCommand(CommandSender sender, String label, String[] args) {
Player player = (Player) sender;
if(!(player.getName().equals("iie") || player.getName().equals("alisolarflare"))){
if (!(player.getName().equals("iie") || player.getName().equals("alisolarflare"))) {
return false;
}
Location location = player.getLocation();
Entity entity = player.getWorld().spawnEntity(location, EntityType.SHULKER);
Shulker shulker = (Shulker) entity;
shulker.setHealth(10);
shulker.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 1728000, 5, false));
shulker.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1728000, 5, false));
shulker.setAI(false);
shulker.setGlowing(true);
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,22 +6,25 @@ import alisolarflare.modules.Module;
import alisolarflare.modules.events.uhc.commands.AddToUHC;
import alisolarflare.modules.events.uhc.commands.StartMatch;
import alisolarflare.modules.events.uhc.memory.UHCMatch;
import buttondevteam.lib.chat.TBMCChatAPI;
public class UHCModule extends Module {
public UHCMatch match;
public void register(JavaPlugin plugin){
public void register(JavaPlugin plugin) {
registerCommands(plugin);
registerListeners(plugin);
registerMemoryUnits(plugin);
}
private void registerListeners(JavaPlugin plugin) {
}
private void registerCommands(JavaPlugin plugin) {
registerCommand(plugin, "addToUHC", new AddToUHC(this.match));
registerCommand(plugin, "startMatch", new StartMatch(this.match));
TBMCChatAPI.AddCommands(plugin, AddToUHC.class);
}
private void registerMemoryUnits(JavaPlugin plugin){
private void registerMemoryUnits(JavaPlugin plugin) {
match = new UHCMatch(plugin.getConfig(), plugin.getConfig().getString("UHCMatchState"));
}
}

View file

@ -1,58 +1,80 @@
package alisolarflare.modules.events.uhc.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.modules.events.uhc.memory.UHCMatch;
import buttondevteam.lib.chat.TBMCCommandBase;
/**
* 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)}
* @author Alisolarflare
* 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)}
*
* @author Alisolarflare
*/
public class AddToUHC implements CommandExecutor{
public class AddToUHC extends TBMCCommandBase {
private UHCMatch generalMemory;
/**
* 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;
}
/**
* 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 label Name of the command called
* @param args Arguments passed onto /addToUHC by the player
*
* @param sender
* CommandSender which sent the command /addToUHC
* @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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//INPUT SANITATION
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
return false;
}
public boolean OnCommand(CommandSender sender, String label, String[] args) {
// INPUT SANITATION
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");
return false;
}
if (args.length <= 1){
if (args.length <= 1) {
sender.sendMessage("You must supply at least one playername");
}
//Adds players to memory
for (int i = 0; i > args.length; i++){
// Adds players to memory
for (int i = 0; i > args.length; i++) {
generalMemory.matchPlayerUsernames.add(player.getName());
}
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.UHCMatch;
import buttondevteam.lib.chat.TBMCCommandBase;
public class StartMatch implements CommandExecutor {
public class StartMatch extends TBMCCommandBase {
private UHCMatch match;
public StartMatch(UHCMatch match){
public StartMatch(UHCMatch match) {
this.match = match;
}
@Override
public boolean onCommand(CommandSender sender, Command command, 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");
}
public boolean OnCommand(CommandSender sender, String label, String[] args) {
if (match.getMatchState() == MatchState.NULL)
sender.sendMessage("There is no match to begin.");
else if (match.getMatchState() == MatchState.IDLE)
@ -28,8 +28,30 @@ public class StartMatch implements CommandExecutor {
sender.sendMessage("The match has ended! Would you like to restart?");
else
sender.sendMessage("You cannot start a match now, one is already in progress!");
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;
}
@SuppressWarnings("deprecation")
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){
try{

View file

@ -1,16 +1,16 @@
package alisolarflare.modules.magictrick.aliarrow;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.modules.Module;
import buttondevteam.lib.TBMCCoreAPI;
public class AliArrowModule extends Module{
public class AliArrowModule extends Module {
/**
* Registers the plugin, activating listeners, commands, and events
*/
@Override
public void register(JavaPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin);
public void register(JavaPlugin plugin) {
TBMCCoreAPI.RegisterEventsForExceptions(new AliArrowListener(plugin), plugin);
}
}

View file

@ -5,35 +5,33 @@ import org.bukkit.entity.Arrow;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public class AliArrowTask extends BukkitRunnable{
public class AliArrowTask extends BukkitRunnable {
JavaPlugin plugin;
String name;
Arrow arrow;
public AliArrowTask(JavaPlugin plugin, Arrow arrow, String name){
public AliArrowTask(JavaPlugin plugin, Arrow arrow, String name) {
this.name = name;
this.plugin = plugin;
this.arrow = arrow;
}
@Override
public void run() {
if (arrow.isOnGround() || arrow.isDead()){
if (arrow.isOnGround() || arrow.isDead()) {
this.cancel();
}
if (name.equalsIgnoreCase("alisolarflare")){
if (name.equalsIgnoreCase("alisolarflare")) {
arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1);
}
if (name.equalsIgnoreCase("Zanthr")){
if (name.equalsIgnoreCase("Zanthr")) {
arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1);
arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1);
}
if (name.equals("NorbiPeti"))
arrow.getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1);
}
}