Refactored code to make subcommands #23

Merged
alisolarflare merged 6 commits from Refactoring into master 2016-12-17 07:43:27 +00:00
15 changed files with 58 additions and 38 deletions
Showing only changes of commit 27f73ae61f - Show all commits

View file

@ -11,7 +11,7 @@ commands:
description: creates creative boundaries
debug:
description: debug commands
flaircolouring:
flaircolour:
description: flaaairs
fruit:
description: fruits

View file

@ -9,7 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.alipresents.components.alilinks.AliLinkComponent;
import buttondevteam.alipresents.components.cashmob.CashMobComponent;
import buttondevteam.alipresents.components.creativeboundaries.CreativeBoundariesComponent;
import buttondevteam.alipresents.components.flaircolouring.FlairColouringComponent;
import buttondevteam.alipresents.components.flaircolour.FlairColourComponent;
import buttondevteam.alipresents.components.fruit.FruitComponent;
import buttondevteam.alipresents.components.gpower.GPowerComponent;
import buttondevteam.alipresents.components.insurance.InsuranceComponent;
@ -27,7 +27,7 @@ public class AliPresents extends JavaPlugin{
new AliLinkComponent().register(this);
new CashMobComponent().register(this);
new CreativeBoundariesComponent().register(this);
new FlairColouringComponent().register(this);
new FlairColourComponent().register(this);
new FruitComponent().register(this);
new GPowerComponent().register(this);
new InsuranceComponent().register(this);

View file

@ -7,12 +7,14 @@ import org.bukkit.entity.Player;
public abstract class PlayerCommand extends BaseCommand{
/**replaces CommandExecutor functionality*/
@Override
public boolean onCommand(CommandSender commandSender, Command command, String string, String[] args){
return OnCommand(commandSender, string, args);
public boolean onCommand(CommandSender sender, Command command, String string, String[] args){
sender.sendMessage("activating" + string.toString());
return OnCommand(sender, string, args);
}
/**replaces TBMCCommandBase functionality*/
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args){
sender.sendMessage("activating" + alias.toString());
return OnCommand((Player) sender, alias, args);
}
public abstract boolean OnCommand(Player player, String alias, String[] args);

View file

@ -1,10 +1,10 @@
package buttondevteam.alipresents.components.flaircolouring;
package buttondevteam.alipresents.components.flaircolour;
import org.bukkit.DyeColor;
import com.earth2me.essentials.User;
public class FlairColouringAPI {
public class FlairColourAPI {
public static void recolourPlayer(User user, DyeColor dyecolour){
String name = user._getNickname();
String sanitizedName = "";

View file

@ -1,4 +1,4 @@
package buttondevteam.alipresents.components.flaircolouring;
package buttondevteam.alipresents.components.flaircolour;
import java.util.ArrayList;
import java.util.List;
@ -13,15 +13,15 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.earth2me.essentials.Essentials;
import buttondevteam.alipresents.architecture.Component;
import buttondevteam.alipresents.components.flaircolouring.letterdyes.GetLetterDye;
import buttondevteam.alipresents.components.flaircolouring.letterdyes.LetterDye;
import buttondevteam.alipresents.components.flaircolouring.letterdyes.LetterDyeListener;
import buttondevteam.alipresents.components.flaircolouring.portals.FlairMe;
import buttondevteam.alipresents.components.flaircolouring.portals.PlayerProximityLoop;
import buttondevteam.alipresents.components.flaircolouring.portals.PortalListener;
import buttondevteam.alipresents.components.flaircolouring.portals.SetProximityLocation;
import buttondevteam.alipresents.components.flaircolour.letterdyes.GetLetterDye;
import buttondevteam.alipresents.components.flaircolour.letterdyes.LetterDye;
import buttondevteam.alipresents.components.flaircolour.letterdyes.LetterDyeListener;
import buttondevteam.alipresents.components.flaircolour.portals.FlairMe;
import buttondevteam.alipresents.components.flaircolour.portals.PlayerProximityLoop;
import buttondevteam.alipresents.components.flaircolour.portals.PortalListener;
import buttondevteam.alipresents.components.flaircolour.portals.SetProximityLocation;
public class FlairColouringComponent extends Component {
public class FlairColourComponent extends Component {
public List<Player> playersToBeFlaired = new ArrayList<Player>();
@Override
public void register(JavaPlugin plugin) {

View file

@ -1,4 +1,4 @@
package buttondevteam.alipresents.components.flaircolouring.letterdyes;
package buttondevteam.alipresents.components.flaircolour.letterdyes;
import org.bukkit.entity.Player;

View file

@ -1,4 +1,4 @@
package buttondevteam.alipresents.components.flaircolouring.letterdyes;
package buttondevteam.alipresents.components.flaircolour.letterdyes;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;

View file

@ -1,4 +1,4 @@
package buttondevteam.alipresents.components.flaircolouring.letterdyes;
package buttondevteam.alipresents.components.flaircolour.letterdyes;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -12,7 +12,7 @@ import org.bukkit.material.Dye;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import buttondevteam.alipresents.components.flaircolouring.FlairColouringAPI;
import buttondevteam.alipresents.components.flaircolour.FlairColourAPI;
public class LetterDyeListener implements Listener{
private Essentials essentials;
@ -32,7 +32,7 @@ public class LetterDyeListener implements Listener{
Dye dye = (Dye) event.getItem().getData();
User user = essentials.getUser(event.getPlayer());
user.setNickname(FlairColouringAPI.colourShiftRight(user._getNickname(), dye.getColor()));
user.setNickname(FlairColourAPI.colourShiftRight(user._getNickname(), dye.getColor()));
}catch(Exception e){
event.getPlayer().sendMessage(e.getStackTrace().toString());
}

View file

@ -1,18 +1,18 @@
package buttondevteam.alipresents.components.flaircolouring.portals;
package buttondevteam.alipresents.components.flaircolour.portals;
import org.bukkit.entity.Player;
import buttondevteam.alipresents.architecture.commands.PlayerCommand;
import buttondevteam.alipresents.components.flaircolouring.FlairColouringComponent;
import buttondevteam.alipresents.components.flaircolour.FlairColourComponent;
public class FlairMe extends PlayerCommand {
@Override
public String GetCommandPath() {
return "flaircolouring flairme";
return "flaircolour flairme";
}
private FlairColouringComponent component;
public FlairMe(FlairColouringComponent flairDoorComponent) {
private FlairColourComponent component;
public FlairMe(FlairColourComponent flairDoorComponent) {
this.component = flairDoorComponent;
}
@Override

View file

@ -1,4 +1,4 @@
package buttondevteam.alipresents.components.flaircolouring.portals;
package buttondevteam.alipresents.components.flaircolour.portals;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -6,11 +6,11 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import buttondevteam.alipresents.components.flaircolouring.FlairColouringComponent;
import buttondevteam.alipresents.components.flaircolour.FlairColourComponent;
public class PlayerProximityLoop extends BukkitRunnable implements Listener{
private static JavaPlugin plugin;
private static FlairColouringComponent component;
private static FlairColourComponent component;
private static Location startLocation;
private static Location endLocation;
@ -21,7 +21,7 @@ public class PlayerProximityLoop extends BukkitRunnable implements Listener{
private static int eY;
private static int eZ;
public PlayerProximityLoop(JavaPlugin plugin, FlairColouringComponent component) {
public PlayerProximityLoop(JavaPlugin plugin, FlairColourComponent component) {
PlayerProximityLoop.plugin = plugin;
PlayerProximityLoop.component = component;
this.runTaskTimer(plugin, 0, 20);

View file

@ -1,4 +1,4 @@
package buttondevteam.alipresents.components.flaircolouring.portals;
package buttondevteam.alipresents.components.flaircolour.portals;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
@ -13,17 +13,17 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.earth2me.essentials.Essentials;
import buttondevteam.alipresents.components.flaircolouring.FlairColouringAPI;
import buttondevteam.alipresents.components.flaircolouring.FlairColouringComponent;
import buttondevteam.alipresents.components.flaircolour.FlairColourAPI;
import buttondevteam.alipresents.components.flaircolour.FlairColourComponent;
public class PortalListener implements Listener{
public JavaPlugin plugin;
Essentials essentials;
private FlairColouringComponent component;
private FlairColourComponent component;
public PortalListener(JavaPlugin plugin, FlairColouringComponent component) {
public PortalListener(JavaPlugin plugin, FlairColourComponent component) {
this.plugin = plugin;
this.component = component;
this.essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"));
@ -51,7 +51,7 @@ public class PortalListener implements Listener{
Block BottomBlock = player.getWorld().getBlockAt(x,y-4,z); //Block under middle block
if(HigherBlock.getType() == Material.STONE){
FlairColouringAPI.recolourPlayer(essentials.getUser(player), DyeColor.GRAY);
FlairColourAPI.recolourPlayer(essentials.getUser(player), DyeColor.GRAY);
component.playersToBeFlaired.remove(player.getName());
return;
}
@ -67,7 +67,7 @@ public class PortalListener implements Listener{
return;
}
FlairColouringAPI.recolourPlayer(essentials.getUser(player), woolColour);
FlairColourAPI.recolourPlayer(essentials.getUser(player), woolColour);
component.playersToBeFlaired.remove(player.getName());
}

View file

@ -1,4 +1,4 @@
package buttondevteam.alipresents.components.flaircolouring.portals;
package buttondevteam.alipresents.components.flaircolour.portals;
import org.bukkit.entity.Player;
@ -36,4 +36,9 @@ public class SetProximityLocation extends ModCommand{
"change their colour state."
};
}
@Override
public String GetCommandPath() {
return "flaircolour setproximitylocation";
}
}

View file

@ -16,4 +16,8 @@ public class PowerAll extends ModCommand{
"Usage: Type /PowerAll to activate all powers for all players with gpowers"
};
}
@Override
public String GetCommandPath() {
return "gpower powerall";
}
}

View file

@ -17,4 +17,9 @@ public class PowerDown extends PlayerCommand {
"Usage: Type /PowerDown to disable your g-power"
};
}
@Override
public String GetCommandPath() {
return "gpower powerdown";
}
}

View file

@ -17,4 +17,8 @@ public class PowerUp extends PlayerCommand {
"Usage: Type /PowerUp to activate your registered G-Power"
};
}
@Override
public String GetCommandPath() {
return "gpower powerup";
}
}