Shoved AliLinks into AliPresents

This commit is contained in:
alisolarflare 2016-08-05 05:24:28 -04:00
parent 7452825503
commit 8421e2799f
8 changed files with 136 additions and 2 deletions

View file

@ -5,3 +5,7 @@ version: 1.0.0
commands: commands:
alishulker: alishulker:
description: Spawns a shulker at player location. /Alishulker <health> <withereffect> <invisibility=true> <experiencedrops> description: Spawns a shulker at player location. /Alishulker <health> <withereffect> <invisibility=true> <experiencedrops>
pressalilink:
description: Presses an Ali Link. /pressalilink |frequency|
setalilink:
description: Creates an Ali Link. /setalilink |frequency|

View file

@ -2,10 +2,18 @@ package alisolarflare;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.links.AliLinkSubPlugin;
import alisolarflare.shulker.AliShulker;
public class MainPlugin extends JavaPlugin{ public class MainPlugin extends JavaPlugin{
public void onEnable(){ public void onEnable(){
registerSubPlugins();
registerCommands(); registerCommands();
} }
public void registerSubPlugins(){
AliLinkSubPlugin alilinksubplugin = new AliLinkSubPlugin(this);
alilinksubplugin.register();
}
public void registerCommands(){ public void registerCommands(){
getCommand("alishulker").setExecutor(new AliShulker()); getCommand("alishulker").setExecutor(new AliShulker());
} }

View file

@ -0,0 +1,20 @@
package alisolarflare.links;
import java.util.ArrayList;
import java.util.List;
import alisolarflare.MainPlugin;
public class AliLinkSubPlugin{
public List<Link> linkList = new ArrayList<Link>();
public MainPlugin plugin;
public AliLinkSubPlugin(MainPlugin plugin){
this.plugin = plugin;
}
public void register(){
plugin.getCommand("pressalilink").setExecutor(new PressAliLink(this));
plugin.getCommand("setalilink").setExecutor(new SetAliLink(this));
}
}

View file

@ -0,0 +1,20 @@
package alisolarflare.links;
import org.bukkit.Location;
import org.bukkit.Material;
public class Link {
static AliLinkSubPlugin plugin;
String frequency;
Location location;
public Link(AliLinkSubPlugin plugin, String frequency, Location location){
this.frequency = frequency;
this.location = location;
}
public void press() {
location.getBlock().setType(Material.REDSTONE_BLOCK);
UnpressTask unPressTask = new UnpressTask(location);
unPressTask.runTaskTimer(plugin.plugin, 2, 1);
}
}

View file

@ -0,0 +1,28 @@
package alisolarflare.links;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PressAliLink implements CommandExecutor{
private AliLinkSubPlugin subplugin;
public PressAliLink(AliLinkSubPlugin subplugin){
this.subplugin = subplugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args == null){
sender.sendMessage("You must specify a link frequency");
sender.sendMessage("/pressalilink [frequency]");
}
for (Link link: subplugin.linkList){
for (String inputlink: args){
if(inputlink.equals(link.frequency)){
link.press();
}
}
}
return false;
}
}

View file

@ -0,0 +1,34 @@
package alisolarflare.links;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SetAliLink implements CommandExecutor{
AliLinkSubPlugin subplugin;
public SetAliLink(AliLinkSubPlugin plugin){
this.subplugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args == null){
sender.sendMessage("You must specify a link frequency");
sender.sendMessage("/pressalilink [name]");
}
if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!");
}
Player player = (Player) sender;
if (args[1] == null || args[2] == null || args[3] == null){
subplugin.linkList.add(new Link(subplugin, args[0], player.getLocation()));
}
if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2]) && StringUtils.isNumericSpace(args[3])){
subplugin.linkList.add(new Link(subplugin, args[0],new Location(player.getWorld(), Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3]))));
}
return false;
}
}

View file

@ -0,0 +1,20 @@
package alisolarflare.links;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.scheduler.BukkitRunnable;
public class UnpressTask extends BukkitRunnable {
private Location location;
public UnpressTask(Location location){
this.location = location;
}
@SuppressWarnings("deprecation")
@Override
public void run() {
location.getBlock().setType(Material.STAINED_CLAY);
location.getBlock().setData((byte) 14);
}
}

View file

@ -1,4 +1,4 @@
package alisolarflare; package alisolarflare.shulker;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;