Oh god this code is horrible, commented more

This commit is contained in:
alisolarflare 2016-10-30 01:26:32 -04:00
parent 43beadfcc1
commit dccf0a772e
5 changed files with 270 additions and 188 deletions

View file

@ -1,36 +1,32 @@
package alisolarflare.links; package alisolarflare.links;
import java.util.ArrayList; import java.util.List;
import java.util.List;
import alisolarflare.AliPresents;
import alisolarflare.AliPresents; import alisolarflare.links.commands.PressAliLink;
import alisolarflare.links.commands.PressAliLink; import alisolarflare.links.commands.SetAliLink;
import alisolarflare.links.commands.SetAliLink; import alisolarflare.links.entities.Link;
import alisolarflare.links.entities.Link;
public class AliLinkSubPlug{
public class AliLinkSubPlug{ public AliPresents plugin;
public List<Link> linkList = new ArrayList<Link>(); private SetAliLink setAliLink;
public AliPresents plugin;
public AliLinkSubPlug(AliPresents plugin){
@SuppressWarnings("unchecked") this.plugin = plugin;
public AliLinkSubPlug(AliPresents plugin){
this.plugin = plugin;
linkList = (List<Link>) plugin.getConfig().getList("aliLinkList"); }
if(linkList == null || linkList.isEmpty()){ public void register(){
linkList = new ArrayList<Link>(); setAliLink = new SetAliLink(this.plugin);
} plugin.getCommand("setalilink").setExecutor(setAliLink);
plugin.getCommand("pressalilink").setExecutor(new PressAliLink(this, setAliLink));
}
public void register(){ }
plugin.getCommand("pressalilink").setExecutor(new PressAliLink(this)); public void saveLinkList(){
plugin.getCommand("setalilink").setExecutor(new SetAliLink(this)); plugin.getConfig().set("aliLinkList", setAliLink.linkList);
}
} @SuppressWarnings("unchecked")
public void saveLinkList(){ public List<Link> loadLinkList(){
plugin.getConfig().set("aliLinkList", linkList); return (List<Link>) plugin.getConfig().getList("aliLinkList");
} }
@SuppressWarnings("unchecked")
public List<Link> loadLinkList(){ }
return (List<Link>) plugin.getConfig().getList("aliLinkList");
}
}

View file

@ -1,34 +1,36 @@
package alisolarflare.links.commands; package alisolarflare.links.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import alisolarflare.links.AliLinkSubPlug; import alisolarflare.links.AliLinkSubPlug;
import alisolarflare.links.entities.Link; import alisolarflare.links.entities.Link;
public class PressAliLink implements CommandExecutor{ public class PressAliLink implements CommandExecutor{
private AliLinkSubPlug subplugin; private AliLinkSubPlug subplugin;
public PressAliLink(AliLinkSubPlug subplugin){ private SetAliLink setAliLink;
this.subplugin = subplugin; public PressAliLink(AliLinkSubPlug subplugin, SetAliLink setAliLink){
} this.subplugin = subplugin;
@Override this.setAliLink = setAliLink;
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { }
@Override
subplugin.plugin.getServer().broadcastMessage(subplugin.linkList.toString() + "over."); public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 1){ subplugin.plugin.getServer().broadcastMessage(setAliLink.linkList.toString() + "over.");
sender.sendMessage("You must specify a link frequency");
sender.sendMessage("/pressalilink [frequency]"); if (args.length < 1){
} sender.sendMessage("You must specify a link frequency");
for (Link link: subplugin.linkList){ sender.sendMessage("/pressalilink [frequency]");
for (String inputlink: args){ }
if(inputlink.equals(link.frequency)){ for (Link link: setAliLink.linkList){
link.press(subplugin); for (String inputlink: args){
} if(inputlink.equals(link.frequency)){
} link.press(subplugin);
} }
return false; }
} }
return false;
} }
}

View file

@ -1,71 +1,124 @@
package alisolarflare.links.commands; package alisolarflare.links.commands;
import org.apache.commons.lang3.StringUtils; import java.util.ArrayList;
import org.bukkit.Location; import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import alisolarflare.links.AliLinkSubPlug; import org.bukkit.command.CommandSender;
import alisolarflare.links.entities.Link; import org.bukkit.entity.Player;
public class SetAliLink implements CommandExecutor{ import alisolarflare.AliPresents;
AliLinkSubPlug subplugin; import alisolarflare.links.AliLinkSubPlug;
public SetAliLink(AliLinkSubPlug plugin){ import alisolarflare.links.entities.Link;
this.subplugin = plugin;
} /**
@Override * This class manages the command /SetAliLink <frequency> [x] [y] [z]. This command creates an Ali-Link,
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { * a location in a world that when called on by {@link Class#PressAliLink}, creates a temporary redstone block,
sender.sendMessage("you pressed shit"); * enabling wireless redstone
if (args == null || args.length < 1){ *
sender.sendMessage("You must specify a link frequency"); * @see Class#PressAliLink
sender.sendMessage("/pressalilink [name]"); * @author Alisolarflare
return false; *
} */
if (!(sender instanceof Player)){ public class SetAliLink implements CommandExecutor{
sender.sendMessage("You must be a player to use this command!"); public List<Link> linkList = new ArrayList<Link>();
} AliLinkSubPlug subplugin;
Player player = (Player) sender; private AliPresents plugin;
if (args.length < 4){
player.sendMessage("short"); /**
subplugin.linkList.add(new Link(args[0], player.getLocation())); * Constructs the SetAliLink class
save(player); * @param plugin The plugin that contains the configuration file of AliPresents
player.sendMessage("end"); */
return false; public SetAliLink(AliPresents plugin){
} this.plugin = plugin;
if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2]) && StringUtils.isNumericSpace(args[3])){ load();
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); * This command creates an Ali-Link which, when activated by the command /PressAliLink,
player.sendMessage("FINISHED"); * creates a temporary redstone block if and only if /PressAliLink [frequency] matches the frequency
}else{ * saved when /SetAliLink [frequency] is called.
player.sendMessage("UNCUSTOOM"); *
subplugin.linkList.add(new Link(args[0], player.getLocation())); * @see Class#PressAliLink
save(player); * @param sender Player who sent the command
player.sendMessage("UNFINISHED"); * @param command Command Object created
return false; * @param label Name of the command
} * @param args Arguments: [frequency] [x-coordinate] [y-coordinate] [z-coordinate], where the coordinates point
return false; * to the intended location of the Ali-Link
} */
private void save(Player player){ @Override
player.sendMessage("SAAAVING"); public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
player.sendMessage("SAVE FAILED: TELL ALI TO FIX THE SAVE AND UN-COMMENT THE PARAGRAPH SHE COMMENTED"); sender.sendMessage("you pressed shit");
player.sendMessage("Link will only last until next server restart"); if (args == null || args.length < 1){
return; sender.sendMessage("You must specify a link frequency");
/* sender.sendMessage("/pressalilink [name]");
subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList); return false;
try { }
player.sendMessage("SAVIN"); if (!(sender instanceof Player)){
subplugin.plugin.saveConfig(); sender.sendMessage("You must be a player to use this command!");
player.sendMessage("GOOD SAVE"); }
} catch (Exception e) { Player player = (Player) sender;
player.sendMessage("YOU FUCKED STUFF UP"); if (args.length < 4){
// TODO Auto-generated catch block player.sendMessage("short");
e.printStackTrace(); 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();
}
}
}

View file

@ -1,39 +1,47 @@
package alisolarflare.shulker; package alisolarflare.shulker;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker; import org.bukkit.entity.Shulker;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
/**
public class AliShulker implements CommandExecutor { * @author Alisolarflare
* This class is responsible for the command /aliShulker, which in-game spawns
@Override * a shulker that:
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { * Has a health of 10
if (!(sender instanceof Player)){ * Has a wither and invisibility effect present
sender.sendMessage("You must be a player to use this command!"); * Has noAI
return false; * And is Glowing
} */
Player player = (Player) sender; public class AliShulker implements CommandExecutor {
if(!(player.getName().equals("iie"))){
return false; @Override
} public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Location location = player.getLocation(); if (!(sender instanceof Player)){
Entity entity = player.getWorld().spawnEntity(location, EntityType.SHULKER); sender.sendMessage("You must be a player to use this command!");
Shulker shulker = (Shulker) entity; return false;
shulker.setHealth(10); }
Player player = (Player) sender;
shulker.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 1728000, 5, false)); if(!(player.getName().equals("iie") || player.getName().equals("alisolarflare"))){
shulker.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1728000, 5, false)); return false;
shulker.setAI(false); }
shulker.setGlowing(true); Location location = player.getLocation();
Entity entity = player.getWorld().spawnEntity(location, EntityType.SHULKER);
return false; 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;
}
}

View file

@ -13,20 +13,43 @@ import org.bukkit.entity.Player;
public class UHCMatch { public class UHCMatch {
private List<String> matchPlayerUsernames = new ArrayList<String>(); 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){ public void addPlayerToMatch(String playername){
matchPlayerUsernames.add(playername); if (!(matchPlayerUsernames.contains(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());
} }
} }
/**
* 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(){ public void removeAllPlayersFromMatch(){
matchPlayerUsernames.clear(); matchPlayerUsernames.clear();
} }
/**
* Fully de-loads and clears out this match, reverting all values to the initialized setting
*/
public void endMatch(){ public void endMatch(){
matchPlayerUsernames.clear(); matchPlayerUsernames.clear();
} }