Oh god this code is horrible, commented more
This commit is contained in:
parent
43beadfcc1
commit
dccf0a772e
5 changed files with 270 additions and 188 deletions
|
@ -1,36 +1,32 @@
|
|||
package alisolarflare.links;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import alisolarflare.AliPresents;
|
||||
import alisolarflare.links.commands.PressAliLink;
|
||||
import alisolarflare.links.commands.SetAliLink;
|
||||
import alisolarflare.links.entities.Link;
|
||||
|
||||
public class AliLinkSubPlug{
|
||||
public List<Link> linkList = new ArrayList<Link>();
|
||||
public AliPresents plugin;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public AliLinkSubPlug(AliPresents plugin){
|
||||
this.plugin = plugin;
|
||||
linkList = (List<Link>) plugin.getConfig().getList("aliLinkList");
|
||||
if(linkList == null || linkList.isEmpty()){
|
||||
linkList = new ArrayList<Link>();
|
||||
}
|
||||
|
||||
}
|
||||
public void register(){
|
||||
plugin.getCommand("pressalilink").setExecutor(new PressAliLink(this));
|
||||
plugin.getCommand("setalilink").setExecutor(new SetAliLink(this));
|
||||
|
||||
}
|
||||
public void saveLinkList(){
|
||||
plugin.getConfig().set("aliLinkList", linkList);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Link> loadLinkList(){
|
||||
return (List<Link>) plugin.getConfig().getList("aliLinkList");
|
||||
}
|
||||
|
||||
}
|
||||
package alisolarflare.links;
|
||||
import java.util.List;
|
||||
|
||||
import alisolarflare.AliPresents;
|
||||
import alisolarflare.links.commands.PressAliLink;
|
||||
import alisolarflare.links.commands.SetAliLink;
|
||||
import alisolarflare.links.entities.Link;
|
||||
|
||||
public class AliLinkSubPlug{
|
||||
public AliPresents plugin;
|
||||
private SetAliLink setAliLink;
|
||||
|
||||
public AliLinkSubPlug(AliPresents plugin){
|
||||
this.plugin = plugin;
|
||||
|
||||
|
||||
}
|
||||
public void register(){
|
||||
setAliLink = new SetAliLink(this.plugin);
|
||||
plugin.getCommand("setalilink").setExecutor(setAliLink);
|
||||
plugin.getCommand("pressalilink").setExecutor(new PressAliLink(this, setAliLink));
|
||||
|
||||
}
|
||||
public void saveLinkList(){
|
||||
plugin.getConfig().set("aliLinkList", setAliLink.linkList);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Link> loadLinkList(){
|
||||
return (List<Link>) plugin.getConfig().getList("aliLinkList");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,34 +1,36 @@
|
|||
package alisolarflare.links.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import alisolarflare.links.AliLinkSubPlug;
|
||||
import alisolarflare.links.entities.Link;
|
||||
|
||||
public class PressAliLink implements CommandExecutor{
|
||||
private AliLinkSubPlug subplugin;
|
||||
public PressAliLink(AliLinkSubPlug subplugin){
|
||||
this.subplugin = subplugin;
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
subplugin.plugin.getServer().broadcastMessage(subplugin.linkList.toString() + "over.");
|
||||
|
||||
if (args.length < 1){
|
||||
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(subplugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
package alisolarflare.links.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import alisolarflare.links.AliLinkSubPlug;
|
||||
import alisolarflare.links.entities.Link;
|
||||
|
||||
public class PressAliLink implements CommandExecutor{
|
||||
private AliLinkSubPlug subplugin;
|
||||
private SetAliLink setAliLink;
|
||||
public PressAliLink(AliLinkSubPlug subplugin, SetAliLink setAliLink){
|
||||
this.subplugin = subplugin;
|
||||
this.setAliLink = setAliLink;
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
subplugin.plugin.getServer().broadcastMessage(setAliLink.linkList.toString() + "over.");
|
||||
|
||||
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)){
|
||||
link.press(subplugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,71 +1,124 @@
|
|||
package alisolarflare.links.commands;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
import alisolarflare.links.AliLinkSubPlug;
|
||||
import alisolarflare.links.entities.Link;
|
||||
|
||||
public class SetAliLink implements CommandExecutor{
|
||||
AliLinkSubPlug subplugin;
|
||||
public SetAliLink(AliLinkSubPlug plugin){
|
||||
this.subplugin = plugin;
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
sender.sendMessage("you pressed shit");
|
||||
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){
|
||||
player.sendMessage("short");
|
||||
subplugin.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])){
|
||||
player.sendMessage("CUUUSTOM");
|
||||
subplugin.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{
|
||||
player.sendMessage("UNCUSTOOM");
|
||||
subplugin.linkList.add(new Link(args[0], player.getLocation()));
|
||||
save(player);
|
||||
player.sendMessage("UNFINISHED");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
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();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
package alisolarflare.links.commands;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
||||
import alisolarflare.AliPresents;
|
||||
import alisolarflare.links.AliLinkSubPlug;
|
||||
import alisolarflare.links.entities.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 Class#PressAliLink}, creates a temporary redstone block,
|
||||
* enabling wireless redstone
|
||||
*
|
||||
* @see Class#PressAliLink
|
||||
* @author Alisolarflare
|
||||
*
|
||||
*/
|
||||
public class SetAliLink implements CommandExecutor{
|
||||
public List<Link> linkList = new ArrayList<Link>();
|
||||
AliLinkSubPlug subplugin;
|
||||
private AliPresents plugin;
|
||||
|
||||
/**
|
||||
* Constructs the SetAliLink class
|
||||
* @param plugin The plugin that contains the configuration file of AliPresents
|
||||
*/
|
||||
public SetAliLink(AliPresents 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.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
sender.sendMessage("you pressed shit");
|
||||
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){
|
||||
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])){
|
||||
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]))));
|
||||
save(player);
|
||||
player.sendMessage("FINISHED");
|
||||
}else{
|
||||
player.sendMessage("UNCUSTOOM");
|
||||
linkList.add(new Link(args[0], player.getLocation()));
|
||||
save(player);
|
||||
player.sendMessage("UNFINISHED");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 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){
|
||||
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();
|
||||
}
|
||||
*/
|
||||
}
|
||||
/**
|
||||
* Attempts to load the previous saved state of AliLinks, from the plugin
|
||||
* configuration file
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void load(){
|
||||
try{
|
||||
linkList = (List<Link>) plugin.getConfig().getList("aliLinkList");
|
||||
if(linkList == null || linkList.isEmpty()){
|
||||
linkList = new ArrayList<Link>();
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,39 +1,47 @@
|
|||
package alisolarflare.shulker;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Shulker;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class AliShulker implements CommandExecutor {
|
||||
|
||||
@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;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(!(player.getName().equals("iie"))){
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
package alisolarflare.shulker;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Shulker;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
/**
|
||||
* @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 {
|
||||
|
||||
@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;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,20 +13,43 @@ import org.bukkit.entity.Player;
|
|||
public class UHCMatch {
|
||||
private List<String> matchPlayerUsernames = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Adds a player to an Ultrahardcore match, storing their name
|
||||
* @param playername player.getName();
|
||||
*/
|
||||
public void addPlayerToMatch(String playername){
|
||||
matchPlayerUsernames.add(playername);
|
||||
}
|
||||
public void addPlayerToMatch(Player player){
|
||||
matchPlayerUsernames.add(player.toString());
|
||||
}
|
||||
public void removePlayerFromMatch(Player player){
|
||||
if (matchPlayerUsernames.contains(player)){
|
||||
matchPlayerUsernames.remove(player.toString());
|
||||
if (!(matchPlayerUsernames.contains(playername))){
|
||||
matchPlayerUsernames.add(playername);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds a player to an Ultrahardcore match, storing their name
|
||||
* @param player Player to be added
|
||||
*/
|
||||
public void addPlayerToMatch(Player player){
|
||||
if (!(matchPlayerUsernames.contains(player.getName()))){
|
||||
matchPlayerUsernames.add(player.getName());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Removes a player from an Ultrahardcore match, removing their username from the list
|
||||
* @param player
|
||||
*/
|
||||
public void removePlayerFromMatch(Player player){
|
||||
if (matchPlayerUsernames.contains(player)){
|
||||
matchPlayerUsernames.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all players from the match
|
||||
*/
|
||||
public void removeAllPlayersFromMatch(){
|
||||
matchPlayerUsernames.clear();
|
||||
}
|
||||
/**
|
||||
* Fully de-loads and clears out this match, reverting all values to the initialized setting
|
||||
*/
|
||||
public void endMatch(){
|
||||
matchPlayerUsernames.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue