Advertisement
twizmwazin

Untitled

Jan 7th, 2015
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.44 KB | None | 0 0
  1. package in.twizmwaz.cardinal.module.modules.wools;
  2.  
  3. import in.parapengu.commons.utils.StringUtils;
  4. import in.twizmwaz.cardinal.match.Match;
  5. import in.twizmwaz.cardinal.module.Module;
  6. import in.twizmwaz.cardinal.module.ModuleBuilder;
  7. import in.twizmwaz.cardinal.regions.Region;
  8. import in.twizmwaz.cardinal.regions.type.BlockRegion;
  9. import in.twizmwaz.cardinal.teams.PgmTeam;
  10. import org.bukkit.Bukkit;
  11. import org.bukkit.DyeColor;
  12. import org.jdom2.Attribute;
  13. import org.jdom2.Element;
  14.  
  15. import java.util.ArrayList;
  16. import java.util.List;
  17. import java.util.logging.Level;
  18.  
  19. public class WoolObjectiveBuilder implements ModuleBuilder {
  20.  
  21.     @Override
  22.     public List<Module> load(Match match) {
  23.         List<Module> result = new ArrayList<>();
  24.         for (Element element : match.getDocument().getRootElement().getChildren("wools")) {
  25.             for (Element subElement : element.getChildren("wool")) {
  26.                 subElement.setAttributes(element.getAttributes());
  27.                 for (Attribute attribute : subElement.getAttributes()) {
  28.                     System.out.println(attribute.getName());
  29.                 }
  30.                 result.add(getWool(subElement, match));
  31.             }
  32.             for (Element child : element.getChildren("wools")) {
  33.                 child.setAttributes(element.getAttributes());
  34.                 for (Element subChild : child.getChildren("wool")) {
  35.                     subChild.setAttributes(child.getAttributes());
  36.                     for (Attribute attribute : subChild.getAttributes()) {
  37.                         System.out.println(attribute.getName());
  38.                     }
  39.                     result.add(getWool(subChild, match));
  40.                 }
  41.             }
  42.         }
  43.         return result;
  44.     }
  45.    
  46.     private WoolObjective getWool(Element element, Match match) {
  47.  
  48.         PgmTeam team;
  49.         team = match.getTeamById(element.getAttributeValue("team"));
  50.         DyeColor color = StringUtils.convertStringToDyeColor(element.getAttributeValue("color"));
  51.         BlockRegion place = (BlockRegion) Region.getRegion(element.getChildren().get(0));
  52.         String name = color.name() + " Wool";
  53.         if (element.getAttributeValue("name") != null) {
  54.             name = element.getAttributeValue("name");
  55.         }
  56.         String id = element.getAttributeValue("id");
  57.         if (id.equals(null)) id = color.name();
  58.         return new WoolObjective(team, name, id, color, place);
  59.        
  60.     }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement