Started work on refactoring Gpowers
This commit is contained in:
parent
13fb77a273
commit
c517296a0a
5 changed files with 87 additions and 22 deletions
|
@ -0,0 +1,55 @@
|
||||||
|
package buttondevteam.alipresents.components.gpower;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import buttondevteam.alipresents.architecture.commands.ModCommand;
|
||||||
|
import buttondevteam.alipresents.components.gpower.api.GPowerAPI;
|
||||||
|
|
||||||
|
public class ApplyPowerUp extends ModCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean OnCommand(Player player, String alias, String[] args) {
|
||||||
|
if (args.length > 1) //No one's online
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String playerArgument = args[0];
|
||||||
|
|
||||||
|
Player argPlayer = player.getServer().getPlayer(playerArgument);
|
||||||
|
|
||||||
|
if (argPlayer == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Attempted player is not online
|
||||||
|
player.sendMessage(playerArgument + " is not online right now. Players online are: ");
|
||||||
|
player.sendMessage(player.getServer().getOnlinePlayers().toString());
|
||||||
|
|
||||||
|
if (args.length < 2){
|
||||||
|
player.sendMessage("You may apply the effect " + args[1] + "to them");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (args.length < 2){
|
||||||
|
//recolour no colour
|
||||||
|
GPowerAPI.PowerUpPlayer(player);
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
GPowerAPI.PowerUpPlayer(player);
|
||||||
|
//recolour with colour
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String[] GetHelpText(String string){
|
||||||
|
return new String[]{
|
||||||
|
"Usage: /"+GetCommandPath()+"<player> <colour>",
|
||||||
|
"Use this command to apply a gpower colour to players",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String GetCommandPath(){
|
||||||
|
return "gpower applypowerup";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,9 @@ public class GPowerComponent extends Component {
|
||||||
registerCommand(plugin, new Test());
|
registerCommand(plugin, new Test());
|
||||||
registerCommand(plugin, new PowerUp());
|
registerCommand(plugin, new PowerUp());
|
||||||
registerCommand(plugin, new PowerDown());
|
registerCommand(plugin, new PowerDown());
|
||||||
|
|
||||||
|
registerCommand(plugin, new ApplyPowerUp());
|
||||||
|
registerCommand(plugin, new ApplyPowerDown());
|
||||||
registerListener(plugin, new EnchantingLoop(plugin));
|
registerListener(plugin, new EnchantingLoop(plugin));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ public class GPowerAPI{
|
||||||
public static void addPlayer(Player player, String colour, boolean powerIsActive){
|
public static void addPlayer(Player player, String colour, boolean powerIsActive){
|
||||||
poweredPlayerList.put(player.getUniqueId(), new PoweredPlayer(player.getUniqueId(), colour, true));
|
poweredPlayerList.put(player.getUniqueId(), new PoweredPlayer(player.getUniqueId(), colour, true));
|
||||||
}
|
}
|
||||||
|
public static void PowerUpPlayer(Player player, String colour){
|
||||||
|
PowerUpPlayer(player);
|
||||||
|
}
|
||||||
public static void PowerUpPlayer(Player player){
|
public static void PowerUpPlayer(Player player){
|
||||||
player.sendMessage("Powering up!");
|
player.sendMessage("Powering up!");
|
||||||
if(poweredPlayerList.containsKey(player.getUniqueId())){
|
if(poweredPlayerList.containsKey(player.getUniqueId())){
|
||||||
|
@ -33,14 +36,15 @@ public class GPowerAPI{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PowerDownPlayer(Player player){
|
public static boolean PowerDownPlayer(Player player){
|
||||||
player.sendMessage("Powering down!");
|
player.sendMessage("Powering down!");
|
||||||
if (poweredPlayerList.containsKey(player.getUniqueId())){
|
if (poweredPlayerList.containsKey(player.getUniqueId())){
|
||||||
player.sendMessage("Powered down!");
|
player.sendMessage("Powered down!");
|
||||||
poweredPlayerList.get(player.getUniqueId()).isPowersActive = false;
|
poweredPlayerList.get(player.getUniqueId()).isPowersActive = false;
|
||||||
|
return true;
|
||||||
}else{
|
}else{
|
||||||
player.sendMessage("P down!");
|
player.sendMessage("P down!");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,19 @@ import buttondevteam.alipresents.components.magic.tricks.AliArrowListener;
|
||||||
import buttondevteam.alipresents.components.magic.tricks.BoomBowDeathListener;
|
import buttondevteam.alipresents.components.magic.tricks.BoomBowDeathListener;
|
||||||
import buttondevteam.alipresents.components.magic.tricks.BoomBowListener;
|
import buttondevteam.alipresents.components.magic.tricks.BoomBowListener;
|
||||||
import buttondevteam.alipresents.components.magic.tricks.CannonBowListener;
|
import buttondevteam.alipresents.components.magic.tricks.CannonBowListener;
|
||||||
import buttondevteam.alipresents.components.magic.tricks.CannonBowSettings;
|
|
||||||
|
|
||||||
public class MagicComponent extends Component{
|
public class MagicComponent extends Component{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(JavaPlugin plugin) {
|
public void register(JavaPlugin plugin) {
|
||||||
registerCommand(plugin, new CannonBowSettings());
|
//registerCommand(plugin, new CannonBowSettings());
|
||||||
|
|
||||||
registerListener(plugin, new AliArrowListener(plugin));
|
registerListener(plugin, new AliArrowListener(plugin));
|
||||||
registerListener(plugin, new BoomBowDeathListener());
|
registerListener(plugin, new BoomBowDeathListener());
|
||||||
registerListener(plugin, new BoomBowListener(plugin));
|
registerListener(plugin, new BoomBowListener(plugin));
|
||||||
registerListener(plugin, new CannonBowListener(plugin));
|
|
||||||
|
CannonBowListener cbl = new CannonBowListener(plugin);
|
||||||
|
//cbl.loadSettings(plugin.getConfig());
|
||||||
|
registerListener(plugin, cbl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,23 +56,8 @@ public class CannonBowListener implements Listener {
|
||||||
static FileConfiguration config;
|
static FileConfiguration config;
|
||||||
public CannonBowListener(JavaPlugin plugin){
|
public CannonBowListener(JavaPlugin plugin){
|
||||||
config = plugin.getConfig();
|
config = plugin.getConfig();
|
||||||
|
|
||||||
if (config.isDouble(speedMultiplierPath))
|
|
||||||
setSpeedMultiplier(config.getDouble(speedMultiplierPath));
|
|
||||||
|
|
||||||
if (config.isDouble(minForcePath))
|
|
||||||
setMinforce(config.getDouble(minForcePath));
|
|
||||||
|
|
||||||
if (config.isInt(fuseTicksPath))
|
|
||||||
setFuseticks(config.getInt(fuseTicksPath));
|
|
||||||
|
|
||||||
if (config.isDouble(recoilPath))
|
|
||||||
setRecoil(config.getDouble(recoilPath));
|
|
||||||
|
|
||||||
if (config.isBoolean(isDestructivePath))
|
|
||||||
setIsDestructive(config.getBoolean(isDestructivePath));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileLaunch(EntityShootBowEvent event){
|
public void onProjectileLaunch(EntityShootBowEvent event){
|
||||||
//Entity Sanitation
|
//Entity Sanitation
|
||||||
|
@ -247,4 +232,21 @@ public class CannonBowListener implements Listener {
|
||||||
CannonBowListener.isDestructive = isDestructive;
|
CannonBowListener.isDestructive = isDestructive;
|
||||||
config.set(speedMultiplierPath, isDestructive);
|
config.set(speedMultiplierPath, isDestructive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadSettings(FileConfiguration config){
|
||||||
|
if (config.isDouble(speedMultiplierPath))
|
||||||
|
setSpeedMultiplier(config.getDouble(speedMultiplierPath));
|
||||||
|
|
||||||
|
if (config.isDouble(minForcePath))
|
||||||
|
setMinforce(config.getDouble(minForcePath));
|
||||||
|
|
||||||
|
if (config.isInt(fuseTicksPath))
|
||||||
|
setFuseticks(config.getInt(fuseTicksPath));
|
||||||
|
|
||||||
|
if (config.isDouble(recoilPath))
|
||||||
|
setRecoil(config.getDouble(recoilPath));
|
||||||
|
|
||||||
|
if (config.isBoolean(isDestructivePath))
|
||||||
|
setIsDestructive(config.getBoolean(isDestructivePath));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue