repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/client/gui/PageFlipButton.java
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java // @Mod(SOLCarrot.MOD_ID) // @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) // public final class SOLCarrot { // public static final String MOD_ID = "solcarrot"; // // public static final Logger LOGGER = LogManager.getLogger(MOD_ID); // // private static final String PROTOCOL_VERSION = "1.0"; // public static SimpleChannel channel = NetworkRegistry.ChannelBuilder // .named(resourceLocation("main")) // .clientAcceptedVersions(PROTOCOL_VERSION::equals) // .serverAcceptedVersions(PROTOCOL_VERSION::equals) // .networkProtocolVersion(() -> PROTOCOL_VERSION) // .simpleChannel(); // // public static ResourceLocation resourceLocation(String path) { // return new ResourceLocation(MOD_ID, path); // } // // // TODO: not sure if this is even implemented anymore // @SubscribeEvent // public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // // This complains if jar not signed, even if certificateFingerprint is blank // LOGGER.warn("Invalid Fingerprint!"); // } // // @SubscribeEvent // public static void setUp(FMLCommonSetupEvent event) { // channel.messageBuilder(FoodListMessage.class, 0) // .encoder(FoodListMessage::write) // .decoder(FoodListMessage::new) // .consumer(FoodListMessage::handle) // .add(); // } // // public SOLCarrot() { // SOLCarrotConfig.setUp(); // } // }
import com.cazsius.solcarrot.SOLCarrot; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn;
package com.cazsius.solcarrot.client.gui; @OnlyIn(Dist.CLIENT) final class PageFlipButton extends Button {
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java // @Mod(SOLCarrot.MOD_ID) // @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) // public final class SOLCarrot { // public static final String MOD_ID = "solcarrot"; // // public static final Logger LOGGER = LogManager.getLogger(MOD_ID); // // private static final String PROTOCOL_VERSION = "1.0"; // public static SimpleChannel channel = NetworkRegistry.ChannelBuilder // .named(resourceLocation("main")) // .clientAcceptedVersions(PROTOCOL_VERSION::equals) // .serverAcceptedVersions(PROTOCOL_VERSION::equals) // .networkProtocolVersion(() -> PROTOCOL_VERSION) // .simpleChannel(); // // public static ResourceLocation resourceLocation(String path) { // return new ResourceLocation(MOD_ID, path); // } // // // TODO: not sure if this is even implemented anymore // @SubscribeEvent // public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // // This complains if jar not signed, even if certificateFingerprint is blank // LOGGER.warn("Invalid Fingerprint!"); // } // // @SubscribeEvent // public static void setUp(FMLCommonSetupEvent event) { // channel.messageBuilder(FoodListMessage.class, 0) // .encoder(FoodListMessage::write) // .decoder(FoodListMessage::new) // .consumer(FoodListMessage::handle) // .add(); // } // // public SOLCarrot() { // SOLCarrotConfig.setUp(); // } // } // Path: src/main/java/com/cazsius/solcarrot/client/gui/PageFlipButton.java import com.cazsius.solcarrot.SOLCarrot; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; package com.cazsius.solcarrot.client.gui; @OnlyIn(Dist.CLIENT) final class PageFlipButton extends Button {
private static final ResourceLocation texture = SOLCarrot.resourceLocation("textures/gui/food_book.png");
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/communication/FoodListMessage.java
// Path: src/main/java/com/cazsius/solcarrot/tracking/FoodList.java // @ParametersAreNonnullByDefault // public final class FoodList implements FoodCapability { // private static final String NBT_KEY_FOOD_LIST = "foodList"; // // public static FoodList get(PlayerEntity player) { // return (FoodList) player.getCapability(SOLCarrotAPI.foodCapability) // .orElseThrow(FoodListNotFoundException::new); // } // // private final Set<FoodInstance> foods = new HashSet<>(); // // @Nullable // private ProgressInfo cachedProgressInfo; // // public FoodList() {} // // private final LazyOptional<FoodList> capabilityOptional = LazyOptional.of(() -> this); // // @Override // public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction side) { // return capability == SOLCarrotAPI.foodCapability ? capabilityOptional.cast() : LazyOptional.empty(); // } // // /** used for persistent storage */ // @Override // public CompoundNBT serializeNBT() { // CompoundNBT tag = new CompoundNBT(); // // ListNBT list = new ListNBT(); // foods.stream() // .map(FoodInstance::encode) // .filter(Objects::nonNull) // .map(StringNBT::new) // .forEach(list::add); // tag.put(NBT_KEY_FOOD_LIST, list); // // return tag; // } // // /** used for persistent storage */ // @Override // public void deserializeNBT(CompoundNBT tag) { // ListNBT list = tag.getList(NBT_KEY_FOOD_LIST, new StringNBT().getId()); // // foods.clear(); // list.stream() // .map(nbt -> (StringNBT) nbt) // .map(StringNBT::getString) // .map(FoodInstance::decode) // .filter(Objects::nonNull) // .forEach(foods::add); // // invalidateProgressInfo(); // } // // /** @return true if the food was not previously known, i.e. if a new food has been tried */ // public boolean addFood(Item food) { // boolean wasAdded = foods.add(new FoodInstance(food)) && SOLCarrotConfig.shouldCount(food); // invalidateProgressInfo(); // return wasAdded; // } // // @Override // public boolean hasEaten(Item food) { // if (!food.isFood()) return false; // return foods.contains(new FoodInstance(food)); // } // // public void clearFood() { // foods.clear(); // invalidateProgressInfo(); // } // // public Set<FoodInstance> getEatenFoods() { // return new HashSet<>(foods); // } // // // TODO: is this actually desirable? it doesn't filter at all // @Override // public int getEatenFoodCount() { // return foods.size(); // } // // public ProgressInfo getProgressInfo() { // if (cachedProgressInfo == null) { // cachedProgressInfo = new ProgressInfo(this); // } // return cachedProgressInfo; // } // // public void invalidateProgressInfo() { // cachedProgressInfo = null; // } // // public static final class Storage implements Capability.IStorage<FoodCapability> { // @Override // public INBT writeNBT(Capability<FoodCapability> capability, FoodCapability instance, Direction side) { // return instance.serializeNBT(); // } // // @Override // public void readNBT(Capability<FoodCapability> capability, FoodCapability instance, Direction side, INBT tag) { // instance.deserializeNBT((CompoundNBT) tag); // } // } // // public static class FoodListNotFoundException extends RuntimeException { // public FoodListNotFoundException() { // super("Player must have food capability attached, but none was found."); // } // } // }
import com.cazsius.solcarrot.tracking.FoodList; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkEvent; import java.util.function.Supplier;
package com.cazsius.solcarrot.communication; public final class FoodListMessage { private CompoundNBT capabilityNBT;
// Path: src/main/java/com/cazsius/solcarrot/tracking/FoodList.java // @ParametersAreNonnullByDefault // public final class FoodList implements FoodCapability { // private static final String NBT_KEY_FOOD_LIST = "foodList"; // // public static FoodList get(PlayerEntity player) { // return (FoodList) player.getCapability(SOLCarrotAPI.foodCapability) // .orElseThrow(FoodListNotFoundException::new); // } // // private final Set<FoodInstance> foods = new HashSet<>(); // // @Nullable // private ProgressInfo cachedProgressInfo; // // public FoodList() {} // // private final LazyOptional<FoodList> capabilityOptional = LazyOptional.of(() -> this); // // @Override // public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction side) { // return capability == SOLCarrotAPI.foodCapability ? capabilityOptional.cast() : LazyOptional.empty(); // } // // /** used for persistent storage */ // @Override // public CompoundNBT serializeNBT() { // CompoundNBT tag = new CompoundNBT(); // // ListNBT list = new ListNBT(); // foods.stream() // .map(FoodInstance::encode) // .filter(Objects::nonNull) // .map(StringNBT::new) // .forEach(list::add); // tag.put(NBT_KEY_FOOD_LIST, list); // // return tag; // } // // /** used for persistent storage */ // @Override // public void deserializeNBT(CompoundNBT tag) { // ListNBT list = tag.getList(NBT_KEY_FOOD_LIST, new StringNBT().getId()); // // foods.clear(); // list.stream() // .map(nbt -> (StringNBT) nbt) // .map(StringNBT::getString) // .map(FoodInstance::decode) // .filter(Objects::nonNull) // .forEach(foods::add); // // invalidateProgressInfo(); // } // // /** @return true if the food was not previously known, i.e. if a new food has been tried */ // public boolean addFood(Item food) { // boolean wasAdded = foods.add(new FoodInstance(food)) && SOLCarrotConfig.shouldCount(food); // invalidateProgressInfo(); // return wasAdded; // } // // @Override // public boolean hasEaten(Item food) { // if (!food.isFood()) return false; // return foods.contains(new FoodInstance(food)); // } // // public void clearFood() { // foods.clear(); // invalidateProgressInfo(); // } // // public Set<FoodInstance> getEatenFoods() { // return new HashSet<>(foods); // } // // // TODO: is this actually desirable? it doesn't filter at all // @Override // public int getEatenFoodCount() { // return foods.size(); // } // // public ProgressInfo getProgressInfo() { // if (cachedProgressInfo == null) { // cachedProgressInfo = new ProgressInfo(this); // } // return cachedProgressInfo; // } // // public void invalidateProgressInfo() { // cachedProgressInfo = null; // } // // public static final class Storage implements Capability.IStorage<FoodCapability> { // @Override // public INBT writeNBT(Capability<FoodCapability> capability, FoodCapability instance, Direction side) { // return instance.serializeNBT(); // } // // @Override // public void readNBT(Capability<FoodCapability> capability, FoodCapability instance, Direction side, INBT tag) { // instance.deserializeNBT((CompoundNBT) tag); // } // } // // public static class FoodListNotFoundException extends RuntimeException { // public FoodListNotFoundException() { // super("Player must have food capability attached, but none was found."); // } // } // } // Path: src/main/java/com/cazsius/solcarrot/communication/FoodListMessage.java import com.cazsius.solcarrot.tracking.FoodList; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.NetworkEvent; import java.util.function.Supplier; package com.cazsius.solcarrot.communication; public final class FoodListMessage { private CompoundNBT capabilityNBT;
public FoodListMessage(FoodList foodList) {
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/item/FoodBookItem.java
// Path: src/main/java/com/cazsius/solcarrot/client/gui/FoodBookScreen.java // @OnlyIn(Dist.CLIENT) // public final class FoodBookScreen extends Screen implements PageFlipButton.Pageable { // private static final ResourceLocation texture = SOLCarrot.resourceLocation("textures/gui/food_book.png"); // private static final UIImage.Image bookImage = new UIImage.Image(texture, new Rectangle(0, 0, 186, 192)); // static final UIImage.Image carrotImage = new UIImage.Image(texture, new Rectangle(0, 240, 16, 16)); // static final UIImage.Image spiderEyeImage = new UIImage.Image(texture, new Rectangle(16, 240, 16, 16)); // static final UIImage.Image heartImage = new UIImage.Image(texture, new Rectangle(0, 224, 15, 15)); // static final UIImage.Image drumstickImage = new UIImage.Image(texture, new Rectangle(16, 224, 15, 15)); // static final UIImage.Image blacklistImage = new UIImage.Image(texture, new Rectangle(32, 224, 15, 15)); // static final UIImage.Image whitelistImage = new UIImage.Image(texture, new Rectangle(48, 224, 15, 15)); // // static final Color fullBlack = Color.BLACK; // static final Color lessBlack = new Color(0, 0, 0, 128); // static final Color leastBlack = new Color(0, 0, 0, 64); // // private final List<UIElement> elements = new ArrayList<>(); // private UIImage background; // private UILabel pageNumberLabel; // // private PageFlipButton nextPageButton; // private PageFlipButton prevPageButton; // // private PlayerEntity player; // private FoodData foodData; // // private final List<Page> pages = new ArrayList<>(); // private int currentPageNumber = 0; // // public static void open(PlayerEntity player) { // Minecraft.getInstance().displayGuiScreen(new FoodBookScreen(player)); // } // // public FoodBookScreen(PlayerEntity player) { // super(new StringTextComponent("")); // this.player = player; // } // // @Override // public void init() { // super.init(); // // foodData = new FoodData(FoodList.get(player)); // // background = new UIImage(bookImage); // background.setCenterX(width / 2); // background.setCenterY(height / 2); // // elements.clear(); // // // page number // pageNumberLabel = new UILabel("1"); // pageNumberLabel.setCenterX(background.getCenterX()); // pageNumberLabel.setMinY(background.getMinY() + 156); // elements.add(pageNumberLabel); // // initPages(); // // int pageFlipButtonSpacing = 50; // prevPageButton = addButton(new PageFlipButton( // background.getCenterX() - pageFlipButtonSpacing / 2 - PageFlipButton.width, // background.getMinY() + 152, // PageFlipButton.Direction.BACKWARD, // this // )); // nextPageButton = addButton(new PageFlipButton( // background.getCenterX() + pageFlipButtonSpacing / 2, // background.getMinY() + 152, // PageFlipButton.Direction.FORWARD, // this // )); // // updateButtonVisibility(); // } // // private void initPages() { // pages.clear(); // // pages.add(new StatListPage(foodData, background.frame)); // // pages.add(new ConfigInfoPage(foodData, background.frame)); // // addPages("eaten_foods", foodData.eatenFoods); // // if (SOLCarrotConfig.shouldShowUneatenFoods()) { // addPages("uneaten_foods", foodData.uneatenFoods); // } // } // // private void addPages(String headerLocalizationPath, List<Item> items) { // String header = localized("gui", "food_book." + headerLocalizationPath, items.size()); // List<ItemStack> stacks = items.stream().map(ItemStack::new).collect(Collectors.toList()); // pages.addAll(ItemListPage.pages(background.frame, header, stacks)); // } // // @Override // public void render(int mouseX, int mouseY, float partialTicks) { // renderBackground(); // // UIElement.render(background, mouseX, mouseY); // // super.render(mouseX, mouseY, partialTicks); // // if (!pages.isEmpty()) { // might not be loaded yet; race condition // // current page // UIElement.render(elements, mouseX, mouseY); // UIElement.render(pages.get(currentPageNumber), mouseX, mouseY); // } // } // // @Override // public void switchToPage(int pageNumber) { // if (!isWithinRange(pageNumber)) return; // // currentPageNumber = pageNumber; // updateButtonVisibility(); // // pageNumberLabel.text = "" + (currentPageNumber + 1); // } // // @Override // public int getCurrentPageNumber() { // return currentPageNumber; // } // // @Override // public boolean isWithinRange(int pageNumber) { // return pageNumber >= 0 && pageNumber < pages.size(); // } // // private void updateButtonVisibility() { // prevPageButton.updateState(); // nextPageButton.updateState(); // } // }
import com.cazsius.solcarrot.client.gui.FoodBookScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor;
package com.cazsius.solcarrot.item; public final class FoodBookItem extends Item { public FoodBookItem() { super(new Properties().group(ItemGroup.MISC)); } @Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { if (player.isUser()) {
// Path: src/main/java/com/cazsius/solcarrot/client/gui/FoodBookScreen.java // @OnlyIn(Dist.CLIENT) // public final class FoodBookScreen extends Screen implements PageFlipButton.Pageable { // private static final ResourceLocation texture = SOLCarrot.resourceLocation("textures/gui/food_book.png"); // private static final UIImage.Image bookImage = new UIImage.Image(texture, new Rectangle(0, 0, 186, 192)); // static final UIImage.Image carrotImage = new UIImage.Image(texture, new Rectangle(0, 240, 16, 16)); // static final UIImage.Image spiderEyeImage = new UIImage.Image(texture, new Rectangle(16, 240, 16, 16)); // static final UIImage.Image heartImage = new UIImage.Image(texture, new Rectangle(0, 224, 15, 15)); // static final UIImage.Image drumstickImage = new UIImage.Image(texture, new Rectangle(16, 224, 15, 15)); // static final UIImage.Image blacklistImage = new UIImage.Image(texture, new Rectangle(32, 224, 15, 15)); // static final UIImage.Image whitelistImage = new UIImage.Image(texture, new Rectangle(48, 224, 15, 15)); // // static final Color fullBlack = Color.BLACK; // static final Color lessBlack = new Color(0, 0, 0, 128); // static final Color leastBlack = new Color(0, 0, 0, 64); // // private final List<UIElement> elements = new ArrayList<>(); // private UIImage background; // private UILabel pageNumberLabel; // // private PageFlipButton nextPageButton; // private PageFlipButton prevPageButton; // // private PlayerEntity player; // private FoodData foodData; // // private final List<Page> pages = new ArrayList<>(); // private int currentPageNumber = 0; // // public static void open(PlayerEntity player) { // Minecraft.getInstance().displayGuiScreen(new FoodBookScreen(player)); // } // // public FoodBookScreen(PlayerEntity player) { // super(new StringTextComponent("")); // this.player = player; // } // // @Override // public void init() { // super.init(); // // foodData = new FoodData(FoodList.get(player)); // // background = new UIImage(bookImage); // background.setCenterX(width / 2); // background.setCenterY(height / 2); // // elements.clear(); // // // page number // pageNumberLabel = new UILabel("1"); // pageNumberLabel.setCenterX(background.getCenterX()); // pageNumberLabel.setMinY(background.getMinY() + 156); // elements.add(pageNumberLabel); // // initPages(); // // int pageFlipButtonSpacing = 50; // prevPageButton = addButton(new PageFlipButton( // background.getCenterX() - pageFlipButtonSpacing / 2 - PageFlipButton.width, // background.getMinY() + 152, // PageFlipButton.Direction.BACKWARD, // this // )); // nextPageButton = addButton(new PageFlipButton( // background.getCenterX() + pageFlipButtonSpacing / 2, // background.getMinY() + 152, // PageFlipButton.Direction.FORWARD, // this // )); // // updateButtonVisibility(); // } // // private void initPages() { // pages.clear(); // // pages.add(new StatListPage(foodData, background.frame)); // // pages.add(new ConfigInfoPage(foodData, background.frame)); // // addPages("eaten_foods", foodData.eatenFoods); // // if (SOLCarrotConfig.shouldShowUneatenFoods()) { // addPages("uneaten_foods", foodData.uneatenFoods); // } // } // // private void addPages(String headerLocalizationPath, List<Item> items) { // String header = localized("gui", "food_book." + headerLocalizationPath, items.size()); // List<ItemStack> stacks = items.stream().map(ItemStack::new).collect(Collectors.toList()); // pages.addAll(ItemListPage.pages(background.frame, header, stacks)); // } // // @Override // public void render(int mouseX, int mouseY, float partialTicks) { // renderBackground(); // // UIElement.render(background, mouseX, mouseY); // // super.render(mouseX, mouseY, partialTicks); // // if (!pages.isEmpty()) { // might not be loaded yet; race condition // // current page // UIElement.render(elements, mouseX, mouseY); // UIElement.render(pages.get(currentPageNumber), mouseX, mouseY); // } // } // // @Override // public void switchToPage(int pageNumber) { // if (!isWithinRange(pageNumber)) return; // // currentPageNumber = pageNumber; // updateButtonVisibility(); // // pageNumberLabel.text = "" + (currentPageNumber + 1); // } // // @Override // public int getCurrentPageNumber() { // return currentPageNumber; // } // // @Override // public boolean isWithinRange(int pageNumber) { // return pageNumber >= 0 && pageNumber < pages.size(); // } // // private void updateButtonVisibility() { // prevPageButton.updateState(); // nextPageButton.updateState(); // } // } // Path: src/main/java/com/cazsius/solcarrot/item/FoodBookItem.java import com.cazsius.solcarrot.client.gui.FoodBookScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; package com.cazsius.solcarrot.item; public final class FoodBookItem extends Item { public FoodBookItem() { super(new Properties().group(ItemGroup.MISC)); } @Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { if (player.isUser()) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> FoodBookScreen.open(player));
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/tracking/FoodInstance.java
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java // @Mod(SOLCarrot.MOD_ID) // @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) // public final class SOLCarrot { // public static final String MOD_ID = "solcarrot"; // // public static final Logger LOGGER = LogManager.getLogger(MOD_ID); // // private static final String PROTOCOL_VERSION = "1.0"; // public static SimpleChannel channel = NetworkRegistry.ChannelBuilder // .named(resourceLocation("main")) // .clientAcceptedVersions(PROTOCOL_VERSION::equals) // .serverAcceptedVersions(PROTOCOL_VERSION::equals) // .networkProtocolVersion(() -> PROTOCOL_VERSION) // .simpleChannel(); // // public static ResourceLocation resourceLocation(String path) { // return new ResourceLocation(MOD_ID, path); // } // // // TODO: not sure if this is even implemented anymore // @SubscribeEvent // public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // // This complains if jar not signed, even if certificateFingerprint is blank // LOGGER.warn("Invalid Fingerprint!"); // } // // @SubscribeEvent // public static void setUp(FMLCommonSetupEvent event) { // channel.messageBuilder(FoodListMessage.class, 0) // .encoder(FoodListMessage::write) // .decoder(FoodListMessage::new) // .consumer(FoodListMessage::handle) // .add(); // } // // public SOLCarrot() { // SOLCarrotConfig.setUp(); // } // }
import com.cazsius.solcarrot.SOLCarrot; import net.minecraft.item.*; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nullable; import java.util.Objects; import java.util.Optional;
package com.cazsius.solcarrot.tracking; public final class FoodInstance { public final Item item; public FoodInstance(Item item) { this.item = item; if (!item.isFood()) throw new RuntimeException("Attempting to construct FoodInstance from non-food item."); } @Nullable public static FoodInstance decode(String encoded) { ResourceLocation name = new ResourceLocation(encoded); // TODO it'd be nice to store (and maybe even count) references to missing items, in case the mod is added back in later Item item = ForgeRegistries.ITEMS.getValue(name); if (item == null) {
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java // @Mod(SOLCarrot.MOD_ID) // @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) // public final class SOLCarrot { // public static final String MOD_ID = "solcarrot"; // // public static final Logger LOGGER = LogManager.getLogger(MOD_ID); // // private static final String PROTOCOL_VERSION = "1.0"; // public static SimpleChannel channel = NetworkRegistry.ChannelBuilder // .named(resourceLocation("main")) // .clientAcceptedVersions(PROTOCOL_VERSION::equals) // .serverAcceptedVersions(PROTOCOL_VERSION::equals) // .networkProtocolVersion(() -> PROTOCOL_VERSION) // .simpleChannel(); // // public static ResourceLocation resourceLocation(String path) { // return new ResourceLocation(MOD_ID, path); // } // // // TODO: not sure if this is even implemented anymore // @SubscribeEvent // public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // // This complains if jar not signed, even if certificateFingerprint is blank // LOGGER.warn("Invalid Fingerprint!"); // } // // @SubscribeEvent // public static void setUp(FMLCommonSetupEvent event) { // channel.messageBuilder(FoodListMessage.class, 0) // .encoder(FoodListMessage::write) // .decoder(FoodListMessage::new) // .consumer(FoodListMessage::handle) // .add(); // } // // public SOLCarrot() { // SOLCarrotConfig.setUp(); // } // } // Path: src/main/java/com/cazsius/solcarrot/tracking/FoodInstance.java import com.cazsius.solcarrot.SOLCarrot; import net.minecraft.item.*; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nullable; import java.util.Objects; import java.util.Optional; package com.cazsius.solcarrot.tracking; public final class FoodInstance { public final Item item; public FoodInstance(Item item) { this.item = item; if (!item.isFood()) throw new RuntimeException("Attempting to construct FoodInstance from non-food item."); } @Nullable public static FoodInstance decode(String encoded) { ResourceLocation name = new ResourceLocation(encoded); // TODO it'd be nice to store (and maybe even count) references to missing items, in case the mod is added back in later Item item = ForgeRegistries.ITEMS.getValue(name); if (item == null) {
SOLCarrot.LOGGER.warn("attempting to load item into food list that is no longer registered: " + encoded + " (removing from list)");
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/client/gui/Page.java
// Path: src/main/java/com/cazsius/solcarrot/lib/Localization.java // @OnlyIn(Dist.CLIENT) // public static String localized(String domain, IForgeRegistryEntry entry, String path, Object... args) { // return I18n.format(keyString(domain, entry, path), args); // }
import com.cazsius.solcarrot.client.gui.elements.*; import java.awt.*; import static com.cazsius.solcarrot.lib.Localization.localized;
package com.cazsius.solcarrot.client.gui; abstract class Page extends UIElement { final UIStack mainStack; final int spacing = 6; Page(Rectangle frame, String header) { super(frame); mainStack = new UIStack(); mainStack.axis = UIStack.Axis.VERTICAL; mainStack.spacing = spacing; UILabel headerLabel = new UILabel(header); mainStack.addChild(headerLabel); mainStack.addChild(makeSeparatorLine()); children.add(mainStack); updateMainStack(); } void updateMainStack() { mainStack.setCenterX(getCenterX()); mainStack.setMinY(getMinY() + 17); mainStack.updateFrames(); } String fraction(int numerator, int denominator) {
// Path: src/main/java/com/cazsius/solcarrot/lib/Localization.java // @OnlyIn(Dist.CLIENT) // public static String localized(String domain, IForgeRegistryEntry entry, String path, Object... args) { // return I18n.format(keyString(domain, entry, path), args); // } // Path: src/main/java/com/cazsius/solcarrot/client/gui/Page.java import com.cazsius.solcarrot.client.gui.elements.*; import java.awt.*; import static com.cazsius.solcarrot.lib.Localization.localized; package com.cazsius.solcarrot.client.gui; abstract class Page extends UIElement { final UIStack mainStack; final int spacing = 6; Page(Rectangle frame, String header) { super(frame); mainStack = new UIStack(); mainStack.axis = UIStack.Axis.VERTICAL; mainStack.spacing = spacing; UILabel headerLabel = new UILabel(header); mainStack.addChild(headerLabel); mainStack.addChild(makeSeparatorLine()); children.add(mainStack); updateMainStack(); } void updateMainStack() { mainStack.setCenterX(getCenterX()); mainStack.setMinY(getMinY() + 17); mainStack.updateFrames(); } String fraction(int numerator, int denominator) {
return localized("gui", "food_book.fraction",
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/SOLCarrot.java
// Path: src/main/java/com/cazsius/solcarrot/communication/FoodListMessage.java // public final class FoodListMessage { // private CompoundNBT capabilityNBT; // // public FoodListMessage(FoodList foodList) { // this.capabilityNBT = foodList.serializeNBT(); // } // // public FoodListMessage(PacketBuffer buffer) { // this.capabilityNBT = buffer.readCompoundTag(); // } // // public void write(PacketBuffer buffer) { // buffer.writeCompoundTag(capabilityNBT); // } // // public void handle(Supplier<NetworkEvent.Context> context) { // DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> Handler.handle(this, context)); // } // // private static class Handler { // static void handle(FoodListMessage message, Supplier<NetworkEvent.Context> context) { // context.get().enqueueWork(() -> { // PlayerEntity player = Minecraft.getInstance().player; // FoodList.get(player).deserializeNBT(message.capabilityNBT); // }); // context.get().setPacketHandled(true); // } // } // }
import com.cazsius.solcarrot.communication.FoodListMessage; import net.minecraft.util.ResourceLocation; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLFingerprintViolationEvent; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.simple.SimpleChannel; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import static net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD;
package com.cazsius.solcarrot; @Mod(SOLCarrot.MOD_ID) @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) public final class SOLCarrot { public static final String MOD_ID = "solcarrot"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); private static final String PROTOCOL_VERSION = "1.0"; public static SimpleChannel channel = NetworkRegistry.ChannelBuilder .named(resourceLocation("main")) .clientAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals) .networkProtocolVersion(() -> PROTOCOL_VERSION) .simpleChannel(); public static ResourceLocation resourceLocation(String path) { return new ResourceLocation(MOD_ID, path); } // TODO: not sure if this is even implemented anymore @SubscribeEvent public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // This complains if jar not signed, even if certificateFingerprint is blank LOGGER.warn("Invalid Fingerprint!"); } @SubscribeEvent public static void setUp(FMLCommonSetupEvent event) {
// Path: src/main/java/com/cazsius/solcarrot/communication/FoodListMessage.java // public final class FoodListMessage { // private CompoundNBT capabilityNBT; // // public FoodListMessage(FoodList foodList) { // this.capabilityNBT = foodList.serializeNBT(); // } // // public FoodListMessage(PacketBuffer buffer) { // this.capabilityNBT = buffer.readCompoundTag(); // } // // public void write(PacketBuffer buffer) { // buffer.writeCompoundTag(capabilityNBT); // } // // public void handle(Supplier<NetworkEvent.Context> context) { // DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> Handler.handle(this, context)); // } // // private static class Handler { // static void handle(FoodListMessage message, Supplier<NetworkEvent.Context> context) { // context.get().enqueueWork(() -> { // PlayerEntity player = Minecraft.getInstance().player; // FoodList.get(player).deserializeNBT(message.capabilityNBT); // }); // context.get().setPacketHandled(true); // } // } // } // Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java import com.cazsius.solcarrot.communication.FoodListMessage; import net.minecraft.util.ResourceLocation; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLFingerprintViolationEvent; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.simple.SimpleChannel; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import static net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD; package com.cazsius.solcarrot; @Mod(SOLCarrot.MOD_ID) @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) public final class SOLCarrot { public static final String MOD_ID = "solcarrot"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); private static final String PROTOCOL_VERSION = "1.0"; public static SimpleChannel channel = NetworkRegistry.ChannelBuilder .named(resourceLocation("main")) .clientAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals) .networkProtocolVersion(() -> PROTOCOL_VERSION) .simpleChannel(); public static ResourceLocation resourceLocation(String path) { return new ResourceLocation(MOD_ID, path); } // TODO: not sure if this is even implemented anymore @SubscribeEvent public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // This complains if jar not signed, even if certificateFingerprint is blank LOGGER.warn("Invalid Fingerprint!"); } @SubscribeEvent public static void setUp(FMLCommonSetupEvent event) {
channel.messageBuilder(FoodListMessage.class, 0)
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/lib/Localization.java
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java // @Mod(SOLCarrot.MOD_ID) // @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) // public final class SOLCarrot { // public static final String MOD_ID = "solcarrot"; // // public static final Logger LOGGER = LogManager.getLogger(MOD_ID); // // private static final String PROTOCOL_VERSION = "1.0"; // public static SimpleChannel channel = NetworkRegistry.ChannelBuilder // .named(resourceLocation("main")) // .clientAcceptedVersions(PROTOCOL_VERSION::equals) // .serverAcceptedVersions(PROTOCOL_VERSION::equals) // .networkProtocolVersion(() -> PROTOCOL_VERSION) // .simpleChannel(); // // public static ResourceLocation resourceLocation(String path) { // return new ResourceLocation(MOD_ID, path); // } // // // TODO: not sure if this is even implemented anymore // @SubscribeEvent // public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // // This complains if jar not signed, even if certificateFingerprint is blank // LOGGER.warn("Invalid Fingerprint!"); // } // // @SubscribeEvent // public static void setUp(FMLCommonSetupEvent event) { // channel.messageBuilder(FoodListMessage.class, 0) // .encoder(FoodListMessage::write) // .decoder(FoodListMessage::new) // .consumer(FoodListMessage::handle) // .add(); // } // // public SOLCarrot() { // SOLCarrotConfig.setUp(); // } // }
import com.cazsius.solcarrot.SOLCarrot; import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.IForgeRegistryEntry;
package com.cazsius.solcarrot.lib; public final class Localization { public static String keyString(String domain, IForgeRegistryEntry entry, String path) { final ResourceLocation location = entry.getRegistryName(); assert location != null; return keyString(domain, location.getPath() + "." + path); } /** e.g. keyString("tooltip", "eaten_status.not_eaten_1") -> "tooltip.solcarrot.eatenStatus.not_eaten_1") */ public static String keyString(String domain, String path) {
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java // @Mod(SOLCarrot.MOD_ID) // @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD) // public final class SOLCarrot { // public static final String MOD_ID = "solcarrot"; // // public static final Logger LOGGER = LogManager.getLogger(MOD_ID); // // private static final String PROTOCOL_VERSION = "1.0"; // public static SimpleChannel channel = NetworkRegistry.ChannelBuilder // .named(resourceLocation("main")) // .clientAcceptedVersions(PROTOCOL_VERSION::equals) // .serverAcceptedVersions(PROTOCOL_VERSION::equals) // .networkProtocolVersion(() -> PROTOCOL_VERSION) // .simpleChannel(); // // public static ResourceLocation resourceLocation(String path) { // return new ResourceLocation(MOD_ID, path); // } // // // TODO: not sure if this is even implemented anymore // @SubscribeEvent // public static void onFingerprintViolation(FMLFingerprintViolationEvent event) { // // This complains if jar not signed, even if certificateFingerprint is blank // LOGGER.warn("Invalid Fingerprint!"); // } // // @SubscribeEvent // public static void setUp(FMLCommonSetupEvent event) { // channel.messageBuilder(FoodListMessage.class, 0) // .encoder(FoodListMessage::write) // .decoder(FoodListMessage::new) // .consumer(FoodListMessage::handle) // .add(); // } // // public SOLCarrot() { // SOLCarrotConfig.setUp(); // } // } // Path: src/main/java/com/cazsius/solcarrot/lib/Localization.java import com.cazsius.solcarrot.SOLCarrot; import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.IForgeRegistryEntry; package com.cazsius.solcarrot.lib; public final class Localization { public static String keyString(String domain, IForgeRegistryEntry entry, String path) { final ResourceLocation location = entry.getRegistryName(); assert location != null; return keyString(domain, location.getPath() + "." + path); } /** e.g. keyString("tooltip", "eaten_status.not_eaten_1") -> "tooltip.solcarrot.eatenStatus.not_eaten_1") */ public static String keyString(String domain, String path) {
return domain + "." + SOLCarrot.MOD_ID + "." + path;
Cazsius/Spice-of-Life-Carrot-Edition
src/main/java/com/cazsius/solcarrot/client/gui/ItemListPage.java
// Path: src/main/java/com/cazsius/solcarrot/client/gui/elements/UIItemStack.java // public class UIItemStack extends UIElement { // public static final int size = 16; // // public ItemStack itemStack; // // public UIItemStack(ItemStack itemStack) { // super(new Rectangle(size, size)); // // this.itemStack = itemStack; // } // // @Override // protected void render() { // super.render(); // // mc.getItemRenderer().renderItemIntoGUI( // itemStack, // frame.x + (frame.width - size) / 2, // frame.y + (frame.height - size) / 2 // ); // } // // @Override // protected boolean hasTooltip() { // return true; // } // // @Override // protected void renderTooltip(int mouseX, int mouseY) { // List<ITextComponent> tooltip = itemStack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? ADVANCED : NORMAL); // renderTooltip(itemStack, tooltip, mouseX, mouseY); // } // }
import com.cazsius.solcarrot.client.gui.elements.UIItemStack; import net.minecraft.item.ItemStack; import java.awt.*; import java.util.ArrayList; import java.util.List;
package com.cazsius.solcarrot.client.gui; final class ItemListPage extends Page { private static final int itemsPerRow = 5; private static final int rowsPerPage = 6; private static final int itemsPerPage = itemsPerRow * rowsPerPage;
// Path: src/main/java/com/cazsius/solcarrot/client/gui/elements/UIItemStack.java // public class UIItemStack extends UIElement { // public static final int size = 16; // // public ItemStack itemStack; // // public UIItemStack(ItemStack itemStack) { // super(new Rectangle(size, size)); // // this.itemStack = itemStack; // } // // @Override // protected void render() { // super.render(); // // mc.getItemRenderer().renderItemIntoGUI( // itemStack, // frame.x + (frame.width - size) / 2, // frame.y + (frame.height - size) / 2 // ); // } // // @Override // protected boolean hasTooltip() { // return true; // } // // @Override // protected void renderTooltip(int mouseX, int mouseY) { // List<ITextComponent> tooltip = itemStack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? ADVANCED : NORMAL); // renderTooltip(itemStack, tooltip, mouseX, mouseY); // } // } // Path: src/main/java/com/cazsius/solcarrot/client/gui/ItemListPage.java import com.cazsius.solcarrot.client.gui.elements.UIItemStack; import net.minecraft.item.ItemStack; import java.awt.*; import java.util.ArrayList; import java.util.List; package com.cazsius.solcarrot.client.gui; final class ItemListPage extends Page { private static final int itemsPerRow = 5; private static final int rowsPerPage = 6; private static final int itemsPerPage = itemsPerRow * rowsPerPage;
private static final int itemSpacing = UIItemStack.size + 4;
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/di/modules/BusModule.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // }
import com.arellomobile.github.app.GithubApi; import com.squareup.otto.Bus; import javax.inject.Singleton; import dagger.Module; import dagger.Provides;
package com.arellomobile.github.di.modules; /** * Date: 20.09.2016 * Time: 20:22 * * @author Yuri Shmakov */ @Module public class BusModule { @Provides @Singleton
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // } // Path: app/src/main/java/com/arellomobile/github/di/modules/BusModule.java import com.arellomobile.github.app.GithubApi; import com.squareup.otto.Bus; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; package com.arellomobile.github.di.modules; /** * Date: 20.09.2016 * Time: 20:22 * * @author Yuri Shmakov */ @Module public class BusModule { @Provides @Singleton
public Bus provideBus(GithubApi authApi) {
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/di/modules/ApiModule.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // }
import com.arellomobile.github.app.GithubApi; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit2.Retrofit;
package com.arellomobile.github.di.modules; /** * Date: 9/2/2016 * Time: 18:54 * * @author Artur Artikov */ @Module(includes = {RetrofitModule.class}) public class ApiModule { @Provides @Singleton
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // } // Path: app/src/main/java/com/arellomobile/github/di/modules/ApiModule.java import com.arellomobile.github.app.GithubApi; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit2.Retrofit; package com.arellomobile.github.di.modules; /** * Date: 9/2/2016 * Time: 18:54 * * @author Artur Artikov */ @Module(includes = {RetrofitModule.class}) public class ApiModule { @Provides @Singleton
public GithubApi provideAuthApi(Retrofit retrofit) {
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/mvp/common/RxUtils.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubError.java // public class GithubError extends Throwable { // public GithubError(ResponseBody responseBody) { // super(getMessage(responseBody)); // } // // private static String getMessage(ResponseBody responseBody) { // try { // return new JSONObject(responseBody.string()).optString("message"); // } catch (JSONException | IOException e) { // e.printStackTrace(); // } // // return "Unknown exception"; // } // }
import java.io.IOException; import com.arellomobile.github.app.GithubError; import retrofit2.Call; import retrofit2.Response; import rx.Observable; import rx.Scheduler; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package com.arellomobile.github.mvp.common; /** * Date: 18.01.2016 * Time: 14:37 * * @author Yuri Shmakov */ public class RxUtils { public static <T> Observable<T> wrapRetrofitCall(final Call<T> call) { return Observable.create(subscriber -> { final Response<T> execute; try { execute = call.execute(); } catch (IOException e) { subscriber.onError(e); return; } if (execute.isSuccess()) { subscriber.onNext(execute.body()); } else {
// Path: app/src/main/java/com/arellomobile/github/app/GithubError.java // public class GithubError extends Throwable { // public GithubError(ResponseBody responseBody) { // super(getMessage(responseBody)); // } // // private static String getMessage(ResponseBody responseBody) { // try { // return new JSONObject(responseBody.string()).optString("message"); // } catch (JSONException | IOException e) { // e.printStackTrace(); // } // // return "Unknown exception"; // } // } // Path: app/src/main/java/com/arellomobile/github/mvp/common/RxUtils.java import java.io.IOException; import com.arellomobile.github.app.GithubError; import retrofit2.Call; import retrofit2.Response; import rx.Observable; import rx.Scheduler; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package com.arellomobile.github.mvp.common; /** * Date: 18.01.2016 * Time: 14:37 * * @author Yuri Shmakov */ public class RxUtils { public static <T> Observable<T> wrapRetrofitCall(final Call<T> call) { return Observable.create(subscriber -> { final Response<T> execute; try { execute = call.execute(); } catch (IOException e) { subscriber.onError(e); return; } if (execute.isSuccess()) { subscriber.onNext(execute.body()); } else {
subscriber.onError(new GithubError(execute.errorBody()));
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/mvp/presenters/RepositoryLikesPresenter.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubApp.java // public class GithubApp extends Application { // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // // sAppComponent = DaggerAppComponent.builder() // .contextModule(new ContextModule(this)) // .build(); // // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/common/RxUtils.java // public class RxUtils { // public static <T> Observable<T> wrapRetrofitCall(final Call<T> call) { // return Observable.create(subscriber -> // { // final Response<T> execute; // try { // execute = call.execute(); // } catch (IOException e) { // subscriber.onError(e); // return; // } // // if (execute.isSuccess()) { // subscriber.onNext(execute.body()); // } else { // subscriber.onError(new GithubError(execute.errorBody())); // } // }); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable) { // return wrapAsync(observable, Schedulers.io()); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable, Scheduler scheduler) { // return observable // .subscribeOn(scheduler) // .observeOn(AndroidSchedulers.mainThread()); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/RepositoryLikesView.java // public interface RepositoryLikesView extends MvpView { // @StateStrategyType(AddToEndSingleStrategy.class) // void updateLikes(List<Integer> inProgress, List<Integer> likedIds); // }
import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import com.arellomobile.github.app.GithubApp; import com.arellomobile.github.mvp.common.RxUtils; import com.arellomobile.github.mvp.views.RepositoryLikesView; import com.arellomobile.mvp.InjectViewState; import com.arellomobile.mvp.MvpPresenter; import com.squareup.otto.Bus; import javax.inject.Inject; import rx.Observable;
package com.arellomobile.github.mvp.presenters; /** * Date: 26.01.2016 * Time: 16:32 * * @author Yuri Shmakov */ @InjectViewState public class RepositoryLikesPresenter extends MvpPresenter<RepositoryLikesView> { public static final String TAG = "RepositoryLikesPresenter"; @Inject Bus mBus; private List<Integer> mInProgress = new ArrayList<>(); private List<Integer> mLikedIds = new ArrayList<>(); public RepositoryLikesPresenter() {
// Path: app/src/main/java/com/arellomobile/github/app/GithubApp.java // public class GithubApp extends Application { // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // // sAppComponent = DaggerAppComponent.builder() // .contextModule(new ContextModule(this)) // .build(); // // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/common/RxUtils.java // public class RxUtils { // public static <T> Observable<T> wrapRetrofitCall(final Call<T> call) { // return Observable.create(subscriber -> // { // final Response<T> execute; // try { // execute = call.execute(); // } catch (IOException e) { // subscriber.onError(e); // return; // } // // if (execute.isSuccess()) { // subscriber.onNext(execute.body()); // } else { // subscriber.onError(new GithubError(execute.errorBody())); // } // }); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable) { // return wrapAsync(observable, Schedulers.io()); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable, Scheduler scheduler) { // return observable // .subscribeOn(scheduler) // .observeOn(AndroidSchedulers.mainThread()); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/RepositoryLikesView.java // public interface RepositoryLikesView extends MvpView { // @StateStrategyType(AddToEndSingleStrategy.class) // void updateLikes(List<Integer> inProgress, List<Integer> likedIds); // } // Path: app/src/main/java/com/arellomobile/github/mvp/presenters/RepositoryLikesPresenter.java import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import com.arellomobile.github.app.GithubApp; import com.arellomobile.github.mvp.common.RxUtils; import com.arellomobile.github.mvp.views.RepositoryLikesView; import com.arellomobile.mvp.InjectViewState; import com.arellomobile.mvp.MvpPresenter; import com.squareup.otto.Bus; import javax.inject.Inject; import rx.Observable; package com.arellomobile.github.mvp.presenters; /** * Date: 26.01.2016 * Time: 16:32 * * @author Yuri Shmakov */ @InjectViewState public class RepositoryLikesPresenter extends MvpPresenter<RepositoryLikesView> { public static final String TAG = "RepositoryLikesPresenter"; @Inject Bus mBus; private List<Integer> mInProgress = new ArrayList<>(); private List<Integer> mLikedIds = new ArrayList<>(); public RepositoryLikesPresenter() {
GithubApp.getAppComponent().inject(this);
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/mvp/presenters/RepositoryLikesPresenter.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubApp.java // public class GithubApp extends Application { // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // // sAppComponent = DaggerAppComponent.builder() // .contextModule(new ContextModule(this)) // .build(); // // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/common/RxUtils.java // public class RxUtils { // public static <T> Observable<T> wrapRetrofitCall(final Call<T> call) { // return Observable.create(subscriber -> // { // final Response<T> execute; // try { // execute = call.execute(); // } catch (IOException e) { // subscriber.onError(e); // return; // } // // if (execute.isSuccess()) { // subscriber.onNext(execute.body()); // } else { // subscriber.onError(new GithubError(execute.errorBody())); // } // }); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable) { // return wrapAsync(observable, Schedulers.io()); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable, Scheduler scheduler) { // return observable // .subscribeOn(scheduler) // .observeOn(AndroidSchedulers.mainThread()); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/RepositoryLikesView.java // public interface RepositoryLikesView extends MvpView { // @StateStrategyType(AddToEndSingleStrategy.class) // void updateLikes(List<Integer> inProgress, List<Integer> likedIds); // }
import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import com.arellomobile.github.app.GithubApp; import com.arellomobile.github.mvp.common.RxUtils; import com.arellomobile.github.mvp.views.RepositoryLikesView; import com.arellomobile.mvp.InjectViewState; import com.arellomobile.mvp.MvpPresenter; import com.squareup.otto.Bus; import javax.inject.Inject; import rx.Observable;
package com.arellomobile.github.mvp.presenters; /** * Date: 26.01.2016 * Time: 16:32 * * @author Yuri Shmakov */ @InjectViewState public class RepositoryLikesPresenter extends MvpPresenter<RepositoryLikesView> { public static final String TAG = "RepositoryLikesPresenter"; @Inject Bus mBus; private List<Integer> mInProgress = new ArrayList<>(); private List<Integer> mLikedIds = new ArrayList<>(); public RepositoryLikesPresenter() { GithubApp.getAppComponent().inject(this); mBus.register(this); } /* // Lice random repositories @Subscribe public void repositoriesLoaded(RepositoriesLoadedEvent repositoriesLoadedEvent) { final Random random = new Random(); for (Repository repository : repositoriesLoadedEvent.getRepositories()) { if (!mInProgress.contains(repository.getId())) { continue; } if (random.nextBoolean()) { mLikedIds.add(repository.getId()); } else { mLikedIds.remove(Integer.valueOf(repository.getId())); } mInProgress.remove(Integer.valueOf(repository.getId())); } getViewState().updateLikes(mInProgress, mLikedIds); } */ public void toggleLike(int id) { if (mInProgress.contains(id)) { return; } mInProgress.add(id); getViewState().updateLikes(mInProgress, mLikedIds); final Observable<Boolean> toggleObservable = Observable.create(subscriber -> { try { TimeUnit.SECONDS.sleep(3); } catch (InterruptedException e) { e.printStackTrace(); } subscriber.onNext(!mLikedIds.contains(id)); });
// Path: app/src/main/java/com/arellomobile/github/app/GithubApp.java // public class GithubApp extends Application { // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // // sAppComponent = DaggerAppComponent.builder() // .contextModule(new ContextModule(this)) // .build(); // // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/common/RxUtils.java // public class RxUtils { // public static <T> Observable<T> wrapRetrofitCall(final Call<T> call) { // return Observable.create(subscriber -> // { // final Response<T> execute; // try { // execute = call.execute(); // } catch (IOException e) { // subscriber.onError(e); // return; // } // // if (execute.isSuccess()) { // subscriber.onNext(execute.body()); // } else { // subscriber.onError(new GithubError(execute.errorBody())); // } // }); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable) { // return wrapAsync(observable, Schedulers.io()); // } // // public static <T> Observable<T> wrapAsync(Observable<T> observable, Scheduler scheduler) { // return observable // .subscribeOn(scheduler) // .observeOn(AndroidSchedulers.mainThread()); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/RepositoryLikesView.java // public interface RepositoryLikesView extends MvpView { // @StateStrategyType(AddToEndSingleStrategy.class) // void updateLikes(List<Integer> inProgress, List<Integer> likedIds); // } // Path: app/src/main/java/com/arellomobile/github/mvp/presenters/RepositoryLikesPresenter.java import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import com.arellomobile.github.app.GithubApp; import com.arellomobile.github.mvp.common.RxUtils; import com.arellomobile.github.mvp.views.RepositoryLikesView; import com.arellomobile.mvp.InjectViewState; import com.arellomobile.mvp.MvpPresenter; import com.squareup.otto.Bus; import javax.inject.Inject; import rx.Observable; package com.arellomobile.github.mvp.presenters; /** * Date: 26.01.2016 * Time: 16:32 * * @author Yuri Shmakov */ @InjectViewState public class RepositoryLikesPresenter extends MvpPresenter<RepositoryLikesView> { public static final String TAG = "RepositoryLikesPresenter"; @Inject Bus mBus; private List<Integer> mInProgress = new ArrayList<>(); private List<Integer> mLikedIds = new ArrayList<>(); public RepositoryLikesPresenter() { GithubApp.getAppComponent().inject(this); mBus.register(this); } /* // Lice random repositories @Subscribe public void repositoriesLoaded(RepositoriesLoadedEvent repositoriesLoadedEvent) { final Random random = new Random(); for (Repository repository : repositoriesLoadedEvent.getRepositories()) { if (!mInProgress.contains(repository.getId())) { continue; } if (random.nextBoolean()) { mLikedIds.add(repository.getId()); } else { mLikedIds.remove(Integer.valueOf(repository.getId())); } mInProgress.remove(Integer.valueOf(repository.getId())); } getViewState().updateLikes(mInProgress, mLikedIds); } */ public void toggleLike(int id) { if (mInProgress.contains(id)) { return; } mInProgress.add(id); getViewState().updateLikes(mInProgress, mLikedIds); final Observable<Boolean> toggleObservable = Observable.create(subscriber -> { try { TimeUnit.SECONDS.sleep(3); } catch (InterruptedException e) { e.printStackTrace(); } subscriber.onNext(!mLikedIds.contains(id)); });
RxUtils.wrapAsync(toggleObservable)
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/mvp/presenters/SignOutPresenter.java
// Path: app/src/main/java/com/arellomobile/github/mvp/common/AuthUtils.java // public class AuthUtils { // private static final String TOKEN = "token"; // // public static String getToken() { // return PrefUtils.getPrefs().getString(TOKEN, ""); // } // // public static void setToken(String token) { // PrefUtils.getEditor().putString(TOKEN, token).commit(); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SignOutView.java // public interface SignOutView extends MvpView { // void signOut(); // }
import com.arellomobile.github.mvp.common.AuthUtils; import com.arellomobile.github.mvp.views.SignOutView; import com.arellomobile.mvp.InjectViewState; import com.arellomobile.mvp.MvpPresenter;
package com.arellomobile.github.mvp.presenters; /** * Date: 18.01.2016 * Time: 16:03 * * @author Yuri Shmakov */ @InjectViewState public class SignOutPresenter extends MvpPresenter<SignOutView> { public void signOut() {
// Path: app/src/main/java/com/arellomobile/github/mvp/common/AuthUtils.java // public class AuthUtils { // private static final String TOKEN = "token"; // // public static String getToken() { // return PrefUtils.getPrefs().getString(TOKEN, ""); // } // // public static void setToken(String token) { // PrefUtils.getEditor().putString(TOKEN, token).commit(); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SignOutView.java // public interface SignOutView extends MvpView { // void signOut(); // } // Path: app/src/main/java/com/arellomobile/github/mvp/presenters/SignOutPresenter.java import com.arellomobile.github.mvp.common.AuthUtils; import com.arellomobile.github.mvp.views.SignOutView; import com.arellomobile.mvp.InjectViewState; import com.arellomobile.mvp.MvpPresenter; package com.arellomobile.github.mvp.presenters; /** * Date: 18.01.2016 * Time: 16:03 * * @author Yuri Shmakov */ @InjectViewState public class SignOutPresenter extends MvpPresenter<SignOutView> { public void signOut() {
AuthUtils.setToken("");
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/di/modules/GithubModule.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // } // // Path: app/src/main/java/com/arellomobile/github/mvp/GithubService.java // public class GithubService { // // private GithubApi mGithubApi; // // public GithubService(GithubApi githubApi) { // mGithubApi = githubApi; // } // // // public Call<User> signIn(String token) { // return mGithubApi.signIn(token); // } // // public Call<List<Repository>> getUserRepos(String user, int page, Integer pageSize) { // return mGithubApi.getUserRepos(user, page, pageSize); // } // }
import com.arellomobile.github.app.GithubApi; import com.arellomobile.github.mvp.GithubService; import javax.inject.Singleton; import dagger.Module; import dagger.Provides;
package com.arellomobile.github.di.modules; /** * Date: 8/26/2016 * Time: 11:58 * * @author Artur Artikov */ @Module(includes = {ApiModule.class}) public class GithubModule { @Provides @Singleton
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // } // // Path: app/src/main/java/com/arellomobile/github/mvp/GithubService.java // public class GithubService { // // private GithubApi mGithubApi; // // public GithubService(GithubApi githubApi) { // mGithubApi = githubApi; // } // // // public Call<User> signIn(String token) { // return mGithubApi.signIn(token); // } // // public Call<List<Repository>> getUserRepos(String user, int page, Integer pageSize) { // return mGithubApi.getUserRepos(user, page, pageSize); // } // } // Path: app/src/main/java/com/arellomobile/github/di/modules/GithubModule.java import com.arellomobile.github.app.GithubApi; import com.arellomobile.github.mvp.GithubService; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; package com.arellomobile.github.di.modules; /** * Date: 8/26/2016 * Time: 11:58 * * @author Artur Artikov */ @Module(includes = {ApiModule.class}) public class GithubModule { @Provides @Singleton
public GithubService provideGithubService(GithubApi authApi) {
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/di/modules/GithubModule.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // } // // Path: app/src/main/java/com/arellomobile/github/mvp/GithubService.java // public class GithubService { // // private GithubApi mGithubApi; // // public GithubService(GithubApi githubApi) { // mGithubApi = githubApi; // } // // // public Call<User> signIn(String token) { // return mGithubApi.signIn(token); // } // // public Call<List<Repository>> getUserRepos(String user, int page, Integer pageSize) { // return mGithubApi.getUserRepos(user, page, pageSize); // } // }
import com.arellomobile.github.app.GithubApi; import com.arellomobile.github.mvp.GithubService; import javax.inject.Singleton; import dagger.Module; import dagger.Provides;
package com.arellomobile.github.di.modules; /** * Date: 8/26/2016 * Time: 11:58 * * @author Artur Artikov */ @Module(includes = {ApiModule.class}) public class GithubModule { @Provides @Singleton
// Path: app/src/main/java/com/arellomobile/github/app/GithubApi.java // public interface GithubApi { // Integer PAGE_SIZE = 50; // // @GET("/user") // Call<User> signIn(@Header("Authorization") String token); // // @GET("/search/repositories?sort=stars&order=desc") // Call<SearchResult> search(@Query("q") String query); // // @GET("/users/{login}/repos") // Call<List<Repository>> getUserRepos(@Path("login") String login, @Query("page") int page, @Query("per_page") int pageSize); // } // // Path: app/src/main/java/com/arellomobile/github/mvp/GithubService.java // public class GithubService { // // private GithubApi mGithubApi; // // public GithubService(GithubApi githubApi) { // mGithubApi = githubApi; // } // // // public Call<User> signIn(String token) { // return mGithubApi.signIn(token); // } // // public Call<List<Repository>> getUserRepos(String user, int page, Integer pageSize) { // return mGithubApi.getUserRepos(user, page, pageSize); // } // } // Path: app/src/main/java/com/arellomobile/github/di/modules/GithubModule.java import com.arellomobile.github.app.GithubApi; import com.arellomobile.github.mvp.GithubService; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; package com.arellomobile.github.di.modules; /** * Date: 8/26/2016 * Time: 11:58 * * @author Artur Artikov */ @Module(includes = {ApiModule.class}) public class GithubModule { @Provides @Singleton
public GithubService provideGithubService(GithubApi authApi) {
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/mvp/presenters/SplashPresenter.java
// Path: app/src/main/java/com/arellomobile/github/mvp/common/AuthUtils.java // public class AuthUtils { // private static final String TOKEN = "token"; // // public static String getToken() { // return PrefUtils.getPrefs().getString(TOKEN, ""); // } // // public static void setToken(String token) { // PrefUtils.getEditor().putString(TOKEN, token).commit(); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SplashView.java // public interface SplashView extends MvpView { // void setAuthorized(boolean isAuthorized); // }
import android.text.TextUtils; import com.arellomobile.github.mvp.common.AuthUtils; import com.arellomobile.github.mvp.views.SplashView; import com.arellomobile.mvp.MvpPresenter; import rx.Observable;
package com.arellomobile.github.mvp.presenters; /** * Date: 18.01.2016 * Time: 15:38 * * @author Yuri Shmakov */ public class SplashPresenter extends MvpPresenter<SplashView> { public void checkAuthorized() {
// Path: app/src/main/java/com/arellomobile/github/mvp/common/AuthUtils.java // public class AuthUtils { // private static final String TOKEN = "token"; // // public static String getToken() { // return PrefUtils.getPrefs().getString(TOKEN, ""); // } // // public static void setToken(String token) { // PrefUtils.getEditor().putString(TOKEN, token).commit(); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SplashView.java // public interface SplashView extends MvpView { // void setAuthorized(boolean isAuthorized); // } // Path: app/src/main/java/com/arellomobile/github/mvp/presenters/SplashPresenter.java import android.text.TextUtils; import com.arellomobile.github.mvp.common.AuthUtils; import com.arellomobile.github.mvp.views.SplashView; import com.arellomobile.mvp.MvpPresenter; import rx.Observable; package com.arellomobile.github.mvp.presenters; /** * Date: 18.01.2016 * Time: 15:38 * * @author Yuri Shmakov */ public class SplashPresenter extends MvpPresenter<SplashView> { public void checkAuthorized() {
final Observable<String> getTokenObservable = Observable.create(subscriber -> subscriber.onNext(AuthUtils.getToken()));
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/ui/activities/SignInActivity.java
// Path: app/src/main/java/com/arellomobile/github/mvp/presenters/SignInPresenter.java // @InjectViewState // public class SignInPresenter extends MvpPresenter<SignInView> { // // @Inject // Context mContext; // @Inject // GithubService mGithubService; // // public SignInPresenter() { // GithubApp.getAppComponent().inject(this); // } // // public void signIn(String email, String password) { // // Integer emailError = null; // Integer passwordError = null; // // getViewState().showError(null, null); // // if (TextUtils.isEmpty(email)) { // emailError = R.string.error_field_required; // } // // if (TextUtils.isEmpty(password)) { // passwordError = R.string.error_invalid_password; // } // // if (emailError != null || passwordError != null) { // getViewState().showError(emailError, passwordError); // // return; // } // // getViewState().showProgress(); // // String credentials = String.format("%s:%s", email, password); // // final String token = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); // // Observable<User> userObservable = RxUtils.wrapRetrofitCall(mGithubService.signIn(token)) // .doOnNext(user -> AuthUtils.setToken(token)); // // RxUtils.wrapAsync(userObservable) // .subscribe(user -> { // getViewState().hideProgress(); // getViewState().successSignIn(); // }, exception -> { // getViewState().hideProgress(); // getViewState().showError(exception.getMessage()); // }); // } // // public void onErrorCancel() { // getViewState().hideError(); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SignInView.java // @StateStrategyType(AddToEndSingleStrategy.class) // public interface SignInView extends MvpView { // void showProgress(); // // void hideProgress(); // // void showError(String message); // // void hideError(); // // void showError(Integer emailError, Integer passwordError); // // @StateStrategyType(SkipStrategy.class) // void successSignIn(); // }
import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import com.arellomobile.github.R; import com.arellomobile.github.mvp.presenters.SignInPresenter; import com.arellomobile.github.mvp.views.SignInView; import com.arellomobile.mvp.MvpAppCompatActivity; import com.arellomobile.mvp.presenter.InjectPresenter; import butterknife.Bind; import butterknife.ButterKnife;
package com.arellomobile.github.ui.activities; /** * A login screen that offers login via email/password. */ public class SignInActivity extends MvpAppCompatActivity implements SignInView, DialogInterface.OnCancelListener { @InjectPresenter
// Path: app/src/main/java/com/arellomobile/github/mvp/presenters/SignInPresenter.java // @InjectViewState // public class SignInPresenter extends MvpPresenter<SignInView> { // // @Inject // Context mContext; // @Inject // GithubService mGithubService; // // public SignInPresenter() { // GithubApp.getAppComponent().inject(this); // } // // public void signIn(String email, String password) { // // Integer emailError = null; // Integer passwordError = null; // // getViewState().showError(null, null); // // if (TextUtils.isEmpty(email)) { // emailError = R.string.error_field_required; // } // // if (TextUtils.isEmpty(password)) { // passwordError = R.string.error_invalid_password; // } // // if (emailError != null || passwordError != null) { // getViewState().showError(emailError, passwordError); // // return; // } // // getViewState().showProgress(); // // String credentials = String.format("%s:%s", email, password); // // final String token = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); // // Observable<User> userObservable = RxUtils.wrapRetrofitCall(mGithubService.signIn(token)) // .doOnNext(user -> AuthUtils.setToken(token)); // // RxUtils.wrapAsync(userObservable) // .subscribe(user -> { // getViewState().hideProgress(); // getViewState().successSignIn(); // }, exception -> { // getViewState().hideProgress(); // getViewState().showError(exception.getMessage()); // }); // } // // public void onErrorCancel() { // getViewState().hideError(); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SignInView.java // @StateStrategyType(AddToEndSingleStrategy.class) // public interface SignInView extends MvpView { // void showProgress(); // // void hideProgress(); // // void showError(String message); // // void hideError(); // // void showError(Integer emailError, Integer passwordError); // // @StateStrategyType(SkipStrategy.class) // void successSignIn(); // } // Path: app/src/main/java/com/arellomobile/github/ui/activities/SignInActivity.java import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import com.arellomobile.github.R; import com.arellomobile.github.mvp.presenters.SignInPresenter; import com.arellomobile.github.mvp.views.SignInView; import com.arellomobile.mvp.MvpAppCompatActivity; import com.arellomobile.mvp.presenter.InjectPresenter; import butterknife.Bind; import butterknife.ButterKnife; package com.arellomobile.github.ui.activities; /** * A login screen that offers login via email/password. */ public class SignInActivity extends MvpAppCompatActivity implements SignInView, DialogInterface.OnCancelListener { @InjectPresenter
SignInPresenter mSignInPresenter;
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/ui/activities/SplashActivity.java
// Path: app/src/main/java/com/arellomobile/github/mvp/presenters/SplashPresenter.java // public class SplashPresenter extends MvpPresenter<SplashView> { // public void checkAuthorized() { // final Observable<String> getTokenObservable = Observable.create(subscriber -> subscriber.onNext(AuthUtils.getToken())); // // getTokenObservable.subscribe(token -> { // for (SplashView splashView : getAttachedViews()) { // splashView.setAuthorized(!TextUtils.isEmpty(token)); // } // }); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SplashView.java // public interface SplashView extends MvpView { // void setAuthorized(boolean isAuthorized); // }
import android.content.Intent; import android.os.Bundle; import com.arellomobile.github.mvp.presenters.SplashPresenter; import com.arellomobile.github.mvp.views.SplashView; import com.arellomobile.mvp.MvpAppCompatActivity; import com.arellomobile.mvp.presenter.InjectPresenter;
package com.arellomobile.github.ui.activities; public class SplashActivity extends MvpAppCompatActivity implements SplashView { @InjectPresenter
// Path: app/src/main/java/com/arellomobile/github/mvp/presenters/SplashPresenter.java // public class SplashPresenter extends MvpPresenter<SplashView> { // public void checkAuthorized() { // final Observable<String> getTokenObservable = Observable.create(subscriber -> subscriber.onNext(AuthUtils.getToken())); // // getTokenObservable.subscribe(token -> { // for (SplashView splashView : getAttachedViews()) { // splashView.setAuthorized(!TextUtils.isEmpty(token)); // } // }); // } // } // // Path: app/src/main/java/com/arellomobile/github/mvp/views/SplashView.java // public interface SplashView extends MvpView { // void setAuthorized(boolean isAuthorized); // } // Path: app/src/main/java/com/arellomobile/github/ui/activities/SplashActivity.java import android.content.Intent; import android.os.Bundle; import com.arellomobile.github.mvp.presenters.SplashPresenter; import com.arellomobile.github.mvp.views.SplashView; import com.arellomobile.mvp.MvpAppCompatActivity; import com.arellomobile.mvp.presenter.InjectPresenter; package com.arellomobile.github.ui.activities; public class SplashActivity extends MvpAppCompatActivity implements SplashView { @InjectPresenter
SplashPresenter mSplashPresenter;
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/app/GithubApp.java
// Path: app/src/main/java/com/arellomobile/github/di/AppComponent.java // @Singleton // @Component(modules = {ContextModule.class, BusModule.class, GithubModule.class}) // public interface AppComponent { // Context getContext(); // GithubService getAuthService(); // Bus getBus(); // // void inject(SignInPresenter presenter); // void inject(RepositoriesPresenter repositoriesPresenter); // void inject(RepositoryLikesPresenter repositoryLikesPresenter); // } // // Path: app/src/main/java/com/arellomobile/github/di/modules/ContextModule.java // @Module // public class ContextModule { // private Context mContext; // // public ContextModule(Context context) { // mContext = context; // } // // @Provides // @Singleton // public Context provideContext() { // return mContext; // } // }
import android.app.Application; import com.arellomobile.github.di.AppComponent; import com.arellomobile.github.di.DaggerAppComponent; import com.arellomobile.github.di.modules.ContextModule;
package com.arellomobile.github.app; /** * Date: 18.01.2016 * Time: 11:22 * * @author Yuri Shmakov */ public class GithubApp extends Application { private static AppComponent sAppComponent; @Override public void onCreate() { super.onCreate(); sAppComponent = DaggerAppComponent.builder()
// Path: app/src/main/java/com/arellomobile/github/di/AppComponent.java // @Singleton // @Component(modules = {ContextModule.class, BusModule.class, GithubModule.class}) // public interface AppComponent { // Context getContext(); // GithubService getAuthService(); // Bus getBus(); // // void inject(SignInPresenter presenter); // void inject(RepositoriesPresenter repositoriesPresenter); // void inject(RepositoryLikesPresenter repositoryLikesPresenter); // } // // Path: app/src/main/java/com/arellomobile/github/di/modules/ContextModule.java // @Module // public class ContextModule { // private Context mContext; // // public ContextModule(Context context) { // mContext = context; // } // // @Provides // @Singleton // public Context provideContext() { // return mContext; // } // } // Path: app/src/main/java/com/arellomobile/github/app/GithubApp.java import android.app.Application; import com.arellomobile.github.di.AppComponent; import com.arellomobile.github.di.DaggerAppComponent; import com.arellomobile.github.di.modules.ContextModule; package com.arellomobile.github.app; /** * Date: 18.01.2016 * Time: 11:22 * * @author Yuri Shmakov */ public class GithubApp extends Application { private static AppComponent sAppComponent; @Override public void onCreate() { super.onCreate(); sAppComponent = DaggerAppComponent.builder()
.contextModule(new ContextModule(this))
Arello-Mobile/MoxySample
app/src/main/java/com/arellomobile/github/mvp/common/PrefUtils.java
// Path: app/src/main/java/com/arellomobile/github/app/GithubApp.java // public class GithubApp extends Application { // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // // sAppComponent = DaggerAppComponent.builder() // .contextModule(new ContextModule(this)) // .build(); // // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // }
import android.content.Context; import android.content.SharedPreferences; import com.arellomobile.github.app.GithubApp;
package com.arellomobile.github.mvp.common; /** * Date: 18.01.2016 * Time: 15:01 * * @author Yuri Shmakov */ public class PrefUtils { private static final String PREF_NAME = "github"; public static SharedPreferences getPrefs() {
// Path: app/src/main/java/com/arellomobile/github/app/GithubApp.java // public class GithubApp extends Application { // private static AppComponent sAppComponent; // // @Override // public void onCreate() { // super.onCreate(); // // sAppComponent = DaggerAppComponent.builder() // .contextModule(new ContextModule(this)) // .build(); // // } // // public static AppComponent getAppComponent() { // return sAppComponent; // } // } // Path: app/src/main/java/com/arellomobile/github/mvp/common/PrefUtils.java import android.content.Context; import android.content.SharedPreferences; import com.arellomobile.github.app.GithubApp; package com.arellomobile.github.mvp.common; /** * Date: 18.01.2016 * Time: 15:01 * * @author Yuri Shmakov */ public class PrefUtils { private static final String PREF_NAME = "github"; public static SharedPreferences getPrefs() {
return GithubApp.getAppComponent().getContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
operator1/op1
op1/src/main/java/com/op1/aiff/InstrumentChunk.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException;
", beginLoop=" + beginLoop + ", endLoop=" + endLoop + '}'; } } @Override public int getPhysicalSize() { return chunkId.getSize() + chunkSize.getSize() + baseNote.getSize() + detune.getSize() + lowNote.getSize() + highNote.getSize() + lowVelocity.getSize() + highVelocity.getSize() + gain.getSize() + sustainLoop.getSize() + releaseLoop.getSize(); } public static class Builder { private final InstrumentChunk instance; public Builder() { this.instance = new InstrumentChunk(); } public InstrumentChunk build() {
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/InstrumentChunk.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; ", beginLoop=" + beginLoop + ", endLoop=" + endLoop + '}'; } } @Override public int getPhysicalSize() { return chunkId.getSize() + chunkSize.getSize() + baseNote.getSize() + detune.getSize() + lowNote.getSize() + highNote.getSize() + lowVelocity.getSize() + highVelocity.getSize() + gain.getSize() + sustainLoop.getSize() + releaseLoop.getSize(); } public static class Builder { private final InstrumentChunk instance; public Builder() { this.instance = new InstrumentChunk(); } public InstrumentChunk build() {
Check.notNull(instance.chunkSize, "Missing chunkSize");
operator1/op1
op1/src/main/java/com/op1/aiff/InstrumentChunk.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException;
instance.highNote = highNote; return this; } public Builder withLowVelocity(SignedChar lowVelocity) { instance.lowVelocity = lowVelocity; return this; } public Builder withHighVelocity(SignedChar highVelocity) { instance.highVelocity = highVelocity; return this; } public Builder withGain(SignedShort gain) { instance.gain = gain; return this; } public Builder withSustainLoop(Loop sustainLoop) { instance.sustainLoop = sustainLoop; return this; } public Builder withReleaseLoop(Loop releaseLoop) { instance.releaseLoop = releaseLoop; return this; } }
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/InstrumentChunk.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; instance.highNote = highNote; return this; } public Builder withLowVelocity(SignedChar lowVelocity) { instance.lowVelocity = lowVelocity; return this; } public Builder withHighVelocity(SignedChar highVelocity) { instance.highVelocity = highVelocity; return this; } public Builder withGain(SignedShort gain) { instance.gain = gain; return this; } public Builder withSustainLoop(Loop sustainLoop) { instance.sustainLoop = sustainLoop; return this; } public Builder withReleaseLoop(Loop releaseLoop) { instance.releaseLoop = releaseLoop; return this; } }
public static InstrumentChunk readInstrumentChunk(IffReader reader) throws IOException {
operator1/op1
op1/src/main/java/com/op1/iff/types/DataType.java
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.util.Check; import java.util.Arrays;
package com.op1.iff.types; public abstract class DataType { protected final byte[] bytes; public DataType(byte[] bytes) { this.bytes = Arrays.copyOf(bytes, bytes.length); } public DataType(byte[] bytes, int expectedNumBytes) {
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/iff/types/DataType.java import com.op1.util.Check; import java.util.Arrays; package com.op1.iff.types; public abstract class DataType { protected final byte[] bytes; public DataType(byte[] bytes) { this.bytes = Arrays.copyOf(bytes, bytes.length); } public DataType(byte[] bytes, int expectedNumBytes) {
Check.that(bytes.length == expectedNumBytes, "Unexpected number of bytes: " + bytes.length);
operator1/op1
op1/src/main/java/com/op1/aiff/MarkerChunk.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List;
} return size; } @Override public ID getChunkID() { return chunkId; } @Override public SignedLong getChunkSize() { return chunkSize; } public UnsignedShort getNumMarkers() { return numMarkers; } public Marker[] getMarkers() { return markers.toArray(new Marker[markers.size()]); } public static class Marker { private final SignedShort markerId; private final UnsignedLong position; private final PString markerName; public Marker(SignedShort markerId, UnsignedLong position, PString markerName) {
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/MarkerChunk.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; } return size; } @Override public ID getChunkID() { return chunkId; } @Override public SignedLong getChunkSize() { return chunkSize; } public UnsignedShort getNumMarkers() { return numMarkers; } public Marker[] getMarkers() { return markers.toArray(new Marker[markers.size()]); } public static class Marker { private final SignedShort markerId; private final UnsignedLong position; private final PString markerName; public Marker(SignedShort markerId, UnsignedLong position, PString markerName) {
Check.notNull(markerId, "Missing markerId");
operator1/op1
op1/src/main/java/com/op1/aiff/MarkerChunk.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List;
private final MarkerChunk instance; public Builder() { instance = new MarkerChunk(); } public MarkerChunk build() { Check.notNull(instance.chunkSize, "Missing chunkSize"); Check.notNull(instance.numMarkers, "Missing numMarkers"); Check.that(instance.markers.size() == instance.numMarkers.toInt(), "Mismatch between markers and numMarkers"); return new MarkerChunk(instance); } public Builder withChunkSize(SignedLong chunkSize) { instance.chunkSize = chunkSize; return this; } public Builder withNumMarkers(UnsignedShort numMarkers) { instance.numMarkers = numMarkers; return this; } public Builder withMarker(Marker marker) { instance.markers.add(marker); return this; } }
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/MarkerChunk.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; private final MarkerChunk instance; public Builder() { instance = new MarkerChunk(); } public MarkerChunk build() { Check.notNull(instance.chunkSize, "Missing chunkSize"); Check.notNull(instance.numMarkers, "Missing numMarkers"); Check.that(instance.markers.size() == instance.numMarkers.toInt(), "Mismatch between markers and numMarkers"); return new MarkerChunk(instance); } public Builder withChunkSize(SignedLong chunkSize) { instance.chunkSize = chunkSize; return this; } public Builder withNumMarkers(UnsignedShort numMarkers) { instance.numMarkers = numMarkers; return this; } public Builder withMarker(Marker marker) { instance.markers.add(marker); return this; } }
public static MarkerChunk readMarkerChunk(IffReader iffReader) throws IOException {
operator1/op1
op1/src/main/java/com/op1/pack/Item.java
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.util.Check;
package com.op1.pack; /** * An immutable holder of a name and a size. Size must be non-zero and positive. */ public class Item { private final String name; private final Double size; public Item(String name, Double size) {
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/pack/Item.java import com.op1.util.Check; package com.op1.pack; /** * An immutable holder of a name and a size. Size must be non-zero and positive. */ public class Item { private final String name; private final Double size; public Item(String name, Double size) {
Check.that(name != null && name.trim().length() > 0, "Must have a name");
operator1/op1
op1/src/main/java/com/op1/iff/Chunk.java
// Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong;
package com.op1.iff; /** * Represents a chunk in an iff. */ public interface Chunk { /** * Returns the ID of this chunk. */ ID getChunkID(); /** * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. */
// Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/main/java/com/op1/iff/Chunk.java import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; package com.op1.iff; /** * Represents a chunk in an iff. */ public interface Chunk { /** * Returns the ID of this chunk. */ ID getChunkID(); /** * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. */
SignedLong getChunkSize();
operator1/op1
op1/src/main/java/com/op1/util/Op1Constants.java
// Path: op1/src/main/java/com/op1/aiff/FormatVersionChunk.java // public class FormatVersionChunk implements Chunk { // // private final ID chunkId = ChunkType.FORMAT_VERSION.getChunkId(); // 4 bytes // private SignedLong chunkSize; // 4 bytes // private UnsignedLong timestamp; // 4 bytes // // private FormatVersionChunk() { // } // // private FormatVersionChunk(FormatVersionChunk chunk) { // this.chunkSize = chunk.getChunkSize(); // this.timestamp = chunk.getTimestamp(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final FormatVersionChunk that = (FormatVersionChunk) o; // // if (chunkId != null ? !chunkId.equals(that.chunkId) : that.chunkId != null) return false; // if (chunkSize != null ? !chunkSize.equals(that.chunkSize) : that.chunkSize != null) return false; // return !(timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null); // // } // // @Override // public int hashCode() { // int result = chunkId != null ? chunkId.hashCode() : 0; // result = 31 * result + (chunkSize != null ? chunkSize.hashCode() : 0); // result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "FormatVersionChunk{" + // "chunkId=" + chunkId + // ", chunkSize=" + chunkSize + // ", timestamp=" + timestamp + // '}'; // } // // @Override // public int getPhysicalSize() { // return chunkId.getSize() // + chunkSize.getSize() // + timestamp.getSize(); // } // // @Override // public ID getChunkID() { // return chunkId; // } // // @Override // public SignedLong getChunkSize() { // return chunkSize; // } // // public UnsignedLong getTimestamp() { // return timestamp; // } // // public static class Builder { // // private final FormatVersionChunk instance; // // public Builder() { // instance = new FormatVersionChunk(); // } // // public FormatVersionChunk build() { // Check.notNull(instance.chunkSize, "Missing chunkSize"); // Check.notNull(instance.timestamp, "Missing timestamp"); // return new FormatVersionChunk(instance); // } // // public Builder withChunkSize(SignedLong chunkSize) { // instance.chunkSize = chunkSize; // return this; // } // // public Builder withTimestamp(UnsignedLong timestamp) { // instance.timestamp = timestamp; // return this; // } // } // // public static FormatVersionChunk readFormatVersionChunk(IffReader reader) throws IOException { // return new FormatVersionChunk.Builder() // .withChunkSize(reader.readSignedLong()) // .withTimestamp(reader.readUnsignedLong()) // .build(); // } // // public static class FormatVersionChunkReader implements ChunkReader { // public Chunk readChunk(IffReader reader) throws IOException { // return readFormatVersionChunk(reader); // } // } // }
import com.op1.aiff.FormatVersionChunk; import com.op1.iff.types.*;
package com.op1.util; public class Op1Constants { public static final Extended SAMPLE_RATE_44100 = new Extended(new byte[]{ 64, 14, -84, 68, 0, 0, 0, 0, 0, 0 }); public static final byte[] COMMON_CHUNK_DESCRIPTION = ")Signed integer (little-endian) linear PCM".getBytes(); public static final OSType APPLICATION_CHUNK_SIGNATURE = OSType.fromString("op-1"); public static final SignedShort NUM_CHANNELS_MONO = SignedShort.fromShort((short) 1); public static final SignedShort SAMPLE_SIZE_16_BIT = SignedShort.fromShort((short) 16); public static final ID ID_SOWT = ID.valueOf("sowt");
// Path: op1/src/main/java/com/op1/aiff/FormatVersionChunk.java // public class FormatVersionChunk implements Chunk { // // private final ID chunkId = ChunkType.FORMAT_VERSION.getChunkId(); // 4 bytes // private SignedLong chunkSize; // 4 bytes // private UnsignedLong timestamp; // 4 bytes // // private FormatVersionChunk() { // } // // private FormatVersionChunk(FormatVersionChunk chunk) { // this.chunkSize = chunk.getChunkSize(); // this.timestamp = chunk.getTimestamp(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final FormatVersionChunk that = (FormatVersionChunk) o; // // if (chunkId != null ? !chunkId.equals(that.chunkId) : that.chunkId != null) return false; // if (chunkSize != null ? !chunkSize.equals(that.chunkSize) : that.chunkSize != null) return false; // return !(timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null); // // } // // @Override // public int hashCode() { // int result = chunkId != null ? chunkId.hashCode() : 0; // result = 31 * result + (chunkSize != null ? chunkSize.hashCode() : 0); // result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "FormatVersionChunk{" + // "chunkId=" + chunkId + // ", chunkSize=" + chunkSize + // ", timestamp=" + timestamp + // '}'; // } // // @Override // public int getPhysicalSize() { // return chunkId.getSize() // + chunkSize.getSize() // + timestamp.getSize(); // } // // @Override // public ID getChunkID() { // return chunkId; // } // // @Override // public SignedLong getChunkSize() { // return chunkSize; // } // // public UnsignedLong getTimestamp() { // return timestamp; // } // // public static class Builder { // // private final FormatVersionChunk instance; // // public Builder() { // instance = new FormatVersionChunk(); // } // // public FormatVersionChunk build() { // Check.notNull(instance.chunkSize, "Missing chunkSize"); // Check.notNull(instance.timestamp, "Missing timestamp"); // return new FormatVersionChunk(instance); // } // // public Builder withChunkSize(SignedLong chunkSize) { // instance.chunkSize = chunkSize; // return this; // } // // public Builder withTimestamp(UnsignedLong timestamp) { // instance.timestamp = timestamp; // return this; // } // } // // public static FormatVersionChunk readFormatVersionChunk(IffReader reader) throws IOException { // return new FormatVersionChunk.Builder() // .withChunkSize(reader.readSignedLong()) // .withTimestamp(reader.readUnsignedLong()) // .build(); // } // // public static class FormatVersionChunkReader implements ChunkReader { // public Chunk readChunk(IffReader reader) throws IOException { // return readFormatVersionChunk(reader); // } // } // } // Path: op1/src/main/java/com/op1/util/Op1Constants.java import com.op1.aiff.FormatVersionChunk; import com.op1.iff.types.*; package com.op1.util; public class Op1Constants { public static final Extended SAMPLE_RATE_44100 = new Extended(new byte[]{ 64, 14, -84, 68, 0, 0, 0, 0, 0, 0 }); public static final byte[] COMMON_CHUNK_DESCRIPTION = ")Signed integer (little-endian) linear PCM".getBytes(); public static final OSType APPLICATION_CHUNK_SIGNATURE = OSType.fromString("op-1"); public static final SignedShort NUM_CHANNELS_MONO = SignedShort.fromShort((short) 1); public static final SignedShort SAMPLE_SIZE_16_BIT = SignedShort.fromShort((short) 16); public static final ID ID_SOWT = ID.valueOf("sowt");
public static final FormatVersionChunk FORMAT_VERSION_CHUNK = new FormatVersionChunk.Builder()
operator1/op1
op1/src/main/java/com/op1/pack/Bin.java
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.util.Check; import java.util.ArrayList; import java.util.Collections; import java.util.List;
package com.op1.pack; /** * A Bin represents a container with a capacity. You can fill the bin with Items. You can also check whether there is * space for an item before putting it in. A Bin can contain more items than its capacity. When this is the case, the * isOverflowing() method returns true. * * This class is not thread safe. */ public class Bin { private final double capacity; private List<Item> items = new ArrayList<Item>(); public Bin(double capacity) {
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/pack/Bin.java import com.op1.util.Check; import java.util.ArrayList; import java.util.Collections; import java.util.List; package com.op1.pack; /** * A Bin represents a container with a capacity. You can fill the bin with Items. You can also check whether there is * space for an item before putting it in. A Bin can contain more items than its capacity. When this is the case, the * isOverflowing() method returns true. * * This class is not thread safe. */ public class Bin { private final double capacity; private List<Item> items = new ArrayList<Item>(); public Bin(double capacity) {
Check.that(capacity > 0, "Capacity must be non-zero and positive");
operator1/op1
op1/src/test/java/com/op1/aiff/AiffTest.java
// Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.junit.Test; import static com.op1.aiff.ChunkType.COMMON; import static com.op1.aiff.ChunkType.SOUND_DATA; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat;
package com.op1.aiff; public class AiffTest { @Test public void canAddMultipleApplicationChunks() throws Exception { // given CommonChunk commonChunk = TestChunks.commonChunkOneSampleFrame16BitMono(); SoundDataChunk soundDataChunk = TestChunks.soundDataChunkOneSampleFrame16BitMono(); ApplicationChunk applicationChunk1 = TestChunks.applicationChunk(); ApplicationChunk applicationChunk2 = TestChunks.applicationChunk(); // when Aiff aiff = new Aiff.Builder()
// Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/test/java/com/op1/aiff/AiffTest.java import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.junit.Test; import static com.op1.aiff.ChunkType.COMMON; import static com.op1.aiff.ChunkType.SOUND_DATA; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; package com.op1.aiff; public class AiffTest { @Test public void canAddMultipleApplicationChunks() throws Exception { // given CommonChunk commonChunk = TestChunks.commonChunkOneSampleFrame16BitMono(); SoundDataChunk soundDataChunk = TestChunks.soundDataChunkOneSampleFrame16BitMono(); ApplicationChunk applicationChunk1 = TestChunks.applicationChunk(); ApplicationChunk applicationChunk2 = TestChunks.applicationChunk(); // when Aiff aiff = new Aiff.Builder()
.withChunkId(new ID("FORM".getBytes()))
operator1/op1
op1/src/test/java/com/op1/aiff/AiffTest.java
// Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.junit.Test; import static com.op1.aiff.ChunkType.COMMON; import static com.op1.aiff.ChunkType.SOUND_DATA; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat;
package com.op1.aiff; public class AiffTest { @Test public void canAddMultipleApplicationChunks() throws Exception { // given CommonChunk commonChunk = TestChunks.commonChunkOneSampleFrame16BitMono(); SoundDataChunk soundDataChunk = TestChunks.soundDataChunkOneSampleFrame16BitMono(); ApplicationChunk applicationChunk1 = TestChunks.applicationChunk(); ApplicationChunk applicationChunk2 = TestChunks.applicationChunk(); // when Aiff aiff = new Aiff.Builder() .withChunkId(new ID("FORM".getBytes()))
// Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/test/java/com/op1/aiff/AiffTest.java import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.junit.Test; import static com.op1.aiff.ChunkType.COMMON; import static com.op1.aiff.ChunkType.SOUND_DATA; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; package com.op1.aiff; public class AiffTest { @Test public void canAddMultipleApplicationChunks() throws Exception { // given CommonChunk commonChunk = TestChunks.commonChunkOneSampleFrame16BitMono(); SoundDataChunk soundDataChunk = TestChunks.soundDataChunkOneSampleFrame16BitMono(); ApplicationChunk applicationChunk1 = TestChunks.applicationChunk(); ApplicationChunk applicationChunk2 = TestChunks.applicationChunk(); // when Aiff aiff = new Aiff.Builder() .withChunkId(new ID("FORM".getBytes()))
.withChunkSize(SignedLong.fromInt(42))
operator1/op1
op1/src/main/java/com/op1/aiff/AiffReader.java
// Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*;
package com.op1.aiff; public class AiffReader implements Closeable { private final IffReader iffReader; private static final Logger LOGGER = LoggerFactory.getLogger(AiffReader.class); public AiffReader(IffReader iffReader) { this.iffReader = iffReader; } public static AiffReader newAiffReader(File file) throws FileNotFoundException { final FileInputStream fileInputStream = new FileInputStream(file); final BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); final DataInputStream dataInputStream = new DataInputStream(bufferedInputStream); final IffReader iffReader = new IffReader(dataInputStream); return new AiffReader(iffReader); } public Aiff readAiff() throws IOException {
// Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/main/java/com/op1/aiff/AiffReader.java import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; package com.op1.aiff; public class AiffReader implements Closeable { private final IffReader iffReader; private static final Logger LOGGER = LoggerFactory.getLogger(AiffReader.class); public AiffReader(IffReader iffReader) { this.iffReader = iffReader; } public static AiffReader newAiffReader(File file) throws FileNotFoundException { final FileInputStream fileInputStream = new FileInputStream(file); final BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); final DataInputStream dataInputStream = new DataInputStream(bufferedInputStream); final IffReader iffReader = new IffReader(dataInputStream); return new AiffReader(iffReader); } public Aiff readAiff() throws IOException {
final ID chunkId = iffReader.readID();
operator1/op1
op1/src/main/java/com/op1/aiff/AiffReader.java
// Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*;
package com.op1.aiff; public class AiffReader implements Closeable { private final IffReader iffReader; private static final Logger LOGGER = LoggerFactory.getLogger(AiffReader.class); public AiffReader(IffReader iffReader) { this.iffReader = iffReader; } public static AiffReader newAiffReader(File file) throws FileNotFoundException { final FileInputStream fileInputStream = new FileInputStream(file); final BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); final DataInputStream dataInputStream = new DataInputStream(bufferedInputStream); final IffReader iffReader = new IffReader(dataInputStream); return new AiffReader(iffReader); } public Aiff readAiff() throws IOException { final ID chunkId = iffReader.readID();
// Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/main/java/com/op1/aiff/AiffReader.java import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; package com.op1.aiff; public class AiffReader implements Closeable { private final IffReader iffReader; private static final Logger LOGGER = LoggerFactory.getLogger(AiffReader.class); public AiffReader(IffReader iffReader) { this.iffReader = iffReader; } public static AiffReader newAiffReader(File file) throws FileNotFoundException { final FileInputStream fileInputStream = new FileInputStream(file); final BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); final DataInputStream dataInputStream = new DataInputStream(bufferedInputStream); final IffReader iffReader = new IffReader(dataInputStream); return new AiffReader(iffReader); } public Aiff readAiff() throws IOException { final ID chunkId = iffReader.readID();
final SignedLong chunkSize = iffReader.readSignedLong();
operator1/op1
op1/src/main/java/com/op1/aiff/CommonChunk.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Optional;
if (!sampleSize.equals(that.sampleSize)) return false; if (!sampleRate.equals(that.sampleRate)) return false; if (!codec.equals(that.codec)) return false; return description.equals(that.description); } @Override public int hashCode() { int result = chunkId.hashCode(); result = 31 * result + chunkSize.hashCode(); result = 31 * result + numChannels.hashCode(); result = 31 * result + numSampleFrames.hashCode(); result = 31 * result + sampleSize.hashCode(); result = 31 * result + sampleRate.hashCode(); result = 31 * result + codec.hashCode(); result = 31 * result + description.hashCode(); return result; } public static class Builder { private final CommonChunk instance; public Builder() { instance = new CommonChunk(); } public CommonChunk build() {
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/CommonChunk.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Optional; if (!sampleSize.equals(that.sampleSize)) return false; if (!sampleRate.equals(that.sampleRate)) return false; if (!codec.equals(that.codec)) return false; return description.equals(that.description); } @Override public int hashCode() { int result = chunkId.hashCode(); result = 31 * result + chunkSize.hashCode(); result = 31 * result + numChannels.hashCode(); result = 31 * result + numSampleFrames.hashCode(); result = 31 * result + sampleSize.hashCode(); result = 31 * result + sampleRate.hashCode(); result = 31 * result + codec.hashCode(); result = 31 * result + description.hashCode(); return result; } public static class Builder { private final CommonChunk instance; public Builder() { instance = new CommonChunk(); } public CommonChunk build() {
Check.notNull(instance.chunkId, "Missing chunkId");
operator1/op1
op1/src/main/java/com/op1/aiff/CommonChunk.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Optional;
instance.sampleSize = sampleSize; return this; } public Builder withSampleRate(Extended sampleRate) { instance.sampleRate = sampleRate; return this; } public Builder withCodec(ID codec) { instance.codec = Optional.ofNullable(codec); return this; } public Builder withDescription(byte[] description) { if (description != null) { final List<Byte> bytes = new ArrayList<>(description.length); for (byte b : description) { bytes.add(b); } instance.description = Optional.of(bytes); } return this; } } /** * It's assumed that the four bytes identifying the common chunk ("COMM") have been read and that the pointer is * pointing to the next byte. */
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/CommonChunk.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.*; import com.op1.util.Check; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Optional; instance.sampleSize = sampleSize; return this; } public Builder withSampleRate(Extended sampleRate) { instance.sampleRate = sampleRate; return this; } public Builder withCodec(ID codec) { instance.codec = Optional.ofNullable(codec); return this; } public Builder withDescription(byte[] description) { if (description != null) { final List<Byte> bytes = new ArrayList<>(description.length); for (byte b : description) { bytes.add(b); } instance.description = Optional.of(bytes); } return this; } } /** * It's assumed that the four bytes identifying the common chunk ("COMM") have been read and that the pointer is * pointing to the next byte. */
public static CommonChunk readCommonChunk(IffReader reader) throws IOException {
operator1/op1
op1/src/main/java/com/op1/aiff/ChunkType.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.util.Check; import java.io.IOException;
package com.op1.aiff; public enum ChunkType { COMMON("COMM", new CommonChunk.CommonChunkReader()), SOUND_DATA("SSND", new SoundDataChunk.SoundDataChunkReader()), MARKER("MARK", new MarkerChunk.MarkerChunkReader()), INSTRUMENT("INST", new InstrumentChunk.InstrumentChunkReader()), APPLICATION("APPL", new ApplicationChunk.ApplicationChunkReader()), FORMAT_VERSION("FVER", new FormatVersionChunk.FormatVersionChunkReader()); // Here are some currently unsupported chunks that need fleshing out: //COMMENT("COMT"), //NAME("NAME"), //AUTHOR("AUTH"), //COPYRIGHT("(c) "), //ANNOTATION("ANNO"), //AUDIO_RECORDING("AESD"), //MIDI_DATA("MIDI"); private final String name;
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/ChunkType.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.util.Check; import java.io.IOException; package com.op1.aiff; public enum ChunkType { COMMON("COMM", new CommonChunk.CommonChunkReader()), SOUND_DATA("SSND", new SoundDataChunk.SoundDataChunkReader()), MARKER("MARK", new MarkerChunk.MarkerChunkReader()), INSTRUMENT("INST", new InstrumentChunk.InstrumentChunkReader()), APPLICATION("APPL", new ApplicationChunk.ApplicationChunkReader()), FORMAT_VERSION("FVER", new FormatVersionChunk.FormatVersionChunkReader()); // Here are some currently unsupported chunks that need fleshing out: //COMMENT("COMT"), //NAME("NAME"), //AUTHOR("AUTH"), //COPYRIGHT("(c) "), //ANNOTATION("ANNO"), //AUDIO_RECORDING("AESD"), //MIDI_DATA("MIDI"); private final String name;
private final ID id;
operator1/op1
op1/src/main/java/com/op1/aiff/ChunkType.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.util.Check; import java.io.IOException;
this.chunkReader = chunkReader; } public ID getChunkId() { return id; } public Chunk readChunk(IffReader reader) throws IOException { return chunkReader.readChunk(reader); } public static ChunkType fromName(String name) { for (ChunkType chunkType : ChunkType.values()) { if (chunkType.name.equals(name)) { return chunkType; } } throw new IllegalArgumentException("Unrecognized chunk"); } public static boolean isKnownChunk(String name) { for (ChunkType chunkType : ChunkType.values()) { if (chunkType.name.equals(name)) { return true; } } return false; } public static boolean isChunkType(Chunk chunk, ChunkType chunkType) {
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/IffReader.java // public class IffReader implements Closeable { // // private final DataInputStream dataInputStream; // // public IffReader(DataInputStream dataInputStream) { // this.dataInputStream = dataInputStream; // } // // public SignedChar readSignedChar() throws IOException { // return new SignedChar(dataInputStream.readByte()); // } // // public UnsignedChar readUnsignedChar() throws IOException { // return new UnsignedChar(dataInputStream.readByte()); // } // // public SignedShort readSignedShort() throws IOException { // return new SignedShort(readBytes(2)); // } // // public UnsignedShort readUnsignedShort() throws IOException { // return new UnsignedShort(readBytes(2)); // } // // public SignedLong readSignedLong() throws IOException { // return new SignedLong(readBytes(4)); // } // // public UnsignedLong readUnsignedLong() throws IOException { // return new UnsignedLong(readBytes(4)); // } // // public Extended readExtended() throws IOException { // return new Extended(readBytes(10)); // } // // public PString readPString() throws IOException { // // // The first byte contains a count of the text textBytes that follow. // final int numTextBytes = dataInputStream.readUnsignedByte(); // // // Read the text bytes. // final byte[] textBytes = readBytes(numTextBytes); // // // The total number of textBytes should be even. A pad byte may have been added to satisfy this rule. // int numPadBytes = (numTextBytes + 1) % 2; // // byte[] pStringBytes = new byte[1 + numTextBytes + numPadBytes]; // pStringBytes[0] = (byte) numTextBytes; // System.arraycopy(textBytes, 0, pStringBytes, 1, textBytes.length); // if (numPadBytes == 1) { // pStringBytes[pStringBytes.length - 1] = dataInputStream.readByte(); // } // return new PString(pStringBytes); // } // // public ID readID() throws IOException { // return new ID(readBytes(4)); // } // // public OSType readOSType() throws IOException { // return new OSType(readBytes(4)); // } // // public byte[] readBytes(int numBytesToRead) throws IOException { // final byte[] bytes = new byte[numBytesToRead]; // final int numRead = dataInputStream.read(bytes); // if (numRead != numBytesToRead) { // throw new EOFException(String.format("numBytesToRead: %s, numRead: %s", numBytesToRead, numRead)); // } // return bytes; // } // // public byte readByte() throws IOException { // return dataInputStream.readByte(); // } // // public void close() throws IOException { // dataInputStream.close(); // } // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/aiff/ChunkType.java import com.op1.iff.Chunk; import com.op1.iff.IffReader; import com.op1.iff.types.ID; import com.op1.util.Check; import java.io.IOException; this.chunkReader = chunkReader; } public ID getChunkId() { return id; } public Chunk readChunk(IffReader reader) throws IOException { return chunkReader.readChunk(reader); } public static ChunkType fromName(String name) { for (ChunkType chunkType : ChunkType.values()) { if (chunkType.name.equals(name)) { return chunkType; } } throw new IllegalArgumentException("Unrecognized chunk"); } public static boolean isKnownChunk(String name) { for (ChunkType chunkType : ChunkType.values()) { if (chunkType.name.equals(name)) { return true; } } return false; } public static boolean isChunkType(Chunk chunk, ChunkType chunkType) {
Check.notNull(chunk, "Chunk is null");
operator1/op1
op1/src/test/java/com/op1/aiff/AiffReaderTest.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.iff.Chunk; import com.op1.iff.types.SignedLong; import org.junit.Test; import java.io.File; import java.util.List; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat;
package com.op1.aiff; public class AiffReaderTest { @Test public void canReadDrumKitFile() throws Exception { doReadFileTest(ExampleFile.DRUM_UTILITY.getFile()); } @Test public void canReadAlbumFile() throws Exception { doReadFileTest(ExampleFile.ALBUM.getFile()); } private void doReadFileTest(File file) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(file); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); } @Test public void canReadDrumPreset1() throws Exception { doCanReadDrumPreset(ExampleFile.DRUM_PRESET_1.getFile()); } private void doCanReadDrumPreset(File drumPreset) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(drumPreset); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); assertHasApplicationChunk(aiff); } private void assertHasApplicationChunk(Aiff aiff) throws Exception { assertThat(aiff, notNullValue());
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/test/java/com/op1/aiff/AiffReaderTest.java import com.op1.iff.Chunk; import com.op1.iff.types.SignedLong; import org.junit.Test; import java.io.File; import java.util.List; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; package com.op1.aiff; public class AiffReaderTest { @Test public void canReadDrumKitFile() throws Exception { doReadFileTest(ExampleFile.DRUM_UTILITY.getFile()); } @Test public void canReadAlbumFile() throws Exception { doReadFileTest(ExampleFile.ALBUM.getFile()); } private void doReadFileTest(File file) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(file); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); } @Test public void canReadDrumPreset1() throws Exception { doCanReadDrumPreset(ExampleFile.DRUM_PRESET_1.getFile()); } private void doCanReadDrumPreset(File drumPreset) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(drumPreset); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); assertHasApplicationChunk(aiff); } private void assertHasApplicationChunk(Aiff aiff) throws Exception { assertThat(aiff, notNullValue());
final List<Chunk> applicationChunks = aiff.getChunks(ChunkType.APPLICATION.getChunkId());
operator1/op1
op1/src/test/java/com/op1/aiff/AiffReaderTest.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.iff.Chunk; import com.op1.iff.types.SignedLong; import org.junit.Test; import java.io.File; import java.util.List; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat;
package com.op1.aiff; public class AiffReaderTest { @Test public void canReadDrumKitFile() throws Exception { doReadFileTest(ExampleFile.DRUM_UTILITY.getFile()); } @Test public void canReadAlbumFile() throws Exception { doReadFileTest(ExampleFile.ALBUM.getFile()); } private void doReadFileTest(File file) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(file); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); } @Test public void canReadDrumPreset1() throws Exception { doCanReadDrumPreset(ExampleFile.DRUM_PRESET_1.getFile()); } private void doCanReadDrumPreset(File drumPreset) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(drumPreset); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); assertHasApplicationChunk(aiff); } private void assertHasApplicationChunk(Aiff aiff) throws Exception { assertThat(aiff, notNullValue()); final List<Chunk> applicationChunks = aiff.getChunks(ChunkType.APPLICATION.getChunkId()); assertThat(applicationChunks.size(), equalTo(1)); final ApplicationChunk applicationChunk = (ApplicationChunk) applicationChunks.get(0);
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/test/java/com/op1/aiff/AiffReaderTest.java import com.op1.iff.Chunk; import com.op1.iff.types.SignedLong; import org.junit.Test; import java.io.File; import java.util.List; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; package com.op1.aiff; public class AiffReaderTest { @Test public void canReadDrumKitFile() throws Exception { doReadFileTest(ExampleFile.DRUM_UTILITY.getFile()); } @Test public void canReadAlbumFile() throws Exception { doReadFileTest(ExampleFile.ALBUM.getFile()); } private void doReadFileTest(File file) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(file); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); } @Test public void canReadDrumPreset1() throws Exception { doCanReadDrumPreset(ExampleFile.DRUM_PRESET_1.getFile()); } private void doCanReadDrumPreset(File drumPreset) throws Exception { // given final AiffReader aiffReader = AiffReader.newAiffReader(drumPreset); // when final Aiff aiff = aiffReader.readAiff(); // then assertThat(aiff, notNullValue()); assertHasApplicationChunk(aiff); } private void assertHasApplicationChunk(Aiff aiff) throws Exception { assertThat(aiff, notNullValue()); final List<Chunk> applicationChunks = aiff.getChunks(ChunkType.APPLICATION.getChunkId()); assertThat(applicationChunks.size(), equalTo(1)); final ApplicationChunk applicationChunk = (ApplicationChunk) applicationChunks.get(0);
assertThat(applicationChunk.getChunkSize(), equalTo(SignedLong.fromInt(1248)));
operator1/op1
op1/src/main/java/com/op1/util/cmd/Args.java
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // }
import com.op1.util.Check;
package com.op1.util.cmd; /** * Represents the arguments passed in on the command line. */ public class Args { private final String[] args; private int index = 0; public Args(String[] args) {
// Path: op1/src/main/java/com/op1/util/Check.java // public class Check { // // public static <T> T notNull(T t, String message) { // if (t == null) { // throw new IllegalArgumentException(message); // } // return t; // } // // public static void that(boolean b, String message) { // if (!b) { // throw new IllegalArgumentException(message); // } // } // // public static void state(boolean b, String message) { // if (!b) { // throw new IllegalStateException(message); // } // } // } // Path: op1/src/main/java/com/op1/util/cmd/Args.java import com.op1.util.Check; package com.op1.util.cmd; /** * Represents the arguments passed in on the command line. */ public class Args { private final String[] args; private int index = 0; public Args(String[] args) {
this.args = Check.notNull(args, "args cannot be null");
operator1/op1
op1/src/main/java/com/op1/util/ComplianceCheck.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.aiff.*; import com.op1.iff.Chunk; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import java.util.ArrayList; import java.util.List; import static com.op1.aiff.ChunkType.APPLICATION; import static java.lang.String.format;
package com.op1.util; public class ComplianceCheck { private final Aiff aiff; private final List<String> problems; public ComplianceCheck(Aiff aiff) { this.aiff = Check.notNull(aiff, "aiff cannot be null"); this.problems = new ArrayList<>(); } /** * @deprecated please use ComplianceCheck.enforceCompliance(Aiff) instead. */ @Deprecated public void enforceCompliance() throws AiffNotCompliantException { checkComplianceOfFormChunk(); if (aiff.getFormType().toString().equals("AIFC")) { checkComplianceOfFormatVersionChunk(); } checkComplianceOfCommonChunk(); checkComplianceOfSoundDataChunk(); if (aiff.hasChunk(APPLICATION)) { checkComplianceOfApplicationChunk(); } if (!problems.isEmpty()) { throw new AiffNotCompliantException(problems); } } public static void enforceCompliance(Aiff aiff) throws AiffNotCompliantException { new ComplianceCheck(aiff).enforceCompliance(); } private void checkComplianceOfFormChunk() { int physicalSizeOfDataPortion = 0; physicalSizeOfDataPortion += aiff.getFormType().getSize();
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/main/java/com/op1/util/ComplianceCheck.java import com.op1.aiff.*; import com.op1.iff.Chunk; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import java.util.ArrayList; import java.util.List; import static com.op1.aiff.ChunkType.APPLICATION; import static java.lang.String.format; package com.op1.util; public class ComplianceCheck { private final Aiff aiff; private final List<String> problems; public ComplianceCheck(Aiff aiff) { this.aiff = Check.notNull(aiff, "aiff cannot be null"); this.problems = new ArrayList<>(); } /** * @deprecated please use ComplianceCheck.enforceCompliance(Aiff) instead. */ @Deprecated public void enforceCompliance() throws AiffNotCompliantException { checkComplianceOfFormChunk(); if (aiff.getFormType().toString().equals("AIFC")) { checkComplianceOfFormatVersionChunk(); } checkComplianceOfCommonChunk(); checkComplianceOfSoundDataChunk(); if (aiff.hasChunk(APPLICATION)) { checkComplianceOfApplicationChunk(); } if (!problems.isEmpty()) { throw new AiffNotCompliantException(problems); } } public static void enforceCompliance(Aiff aiff) throws AiffNotCompliantException { new ComplianceCheck(aiff).enforceCompliance(); } private void checkComplianceOfFormChunk() { int physicalSizeOfDataPortion = 0; physicalSizeOfDataPortion += aiff.getFormType().getSize();
for (List<Chunk> chunksById : aiff.getChunksMap().values()) {
operator1/op1
op1/src/main/java/com/op1/util/ComplianceCheck.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.aiff.*; import com.op1.iff.Chunk; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import java.util.ArrayList; import java.util.List; import static com.op1.aiff.ChunkType.APPLICATION; import static java.lang.String.format;
private void checkComplianceOfCommonChunk() { final CommonChunk chunk = aiff.getCommonChunk(); int physicalSizeOfDataPortion = 0; physicalSizeOfDataPortion += chunk.getNumChannels().getSize(); physicalSizeOfDataPortion += chunk.getNumSampleFrames().getSize(); physicalSizeOfDataPortion += chunk.getSampleSize().getSize(); physicalSizeOfDataPortion += chunk.getSampleRate().getSize(); if (codecAndDescriptionArePresent(chunk.getCodec(), chunk.getDescription())) { physicalSizeOfDataPortion += chunk.getCodec().getSize(); physicalSizeOfDataPortion += chunk.getDescription().length; } int expectedChunkSize = physicalSizeOfDataPortion % 2 == 0 ? physicalSizeOfDataPortion : physicalSizeOfDataPortion + 1; int expectedPhysicalSize = physicalSizeOfDataPortion + 8; if (expectedPhysicalSize % 2 == 1) { expectedPhysicalSize++; } checkChunkSizes(chunk, expectedChunkSize, expectedPhysicalSize); } private void checkChunkSizes(Chunk chunk, int expectedChunkSize, int expectedPhysicalSize) { final String message = format("chunkSize in the %s chunk is %s, was expecting %s", chunk.getChunkID().toString(), chunk.getChunkSize().toInt(), expectedChunkSize);
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/main/java/com/op1/util/ComplianceCheck.java import com.op1.aiff.*; import com.op1.iff.Chunk; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import java.util.ArrayList; import java.util.List; import static com.op1.aiff.ChunkType.APPLICATION; import static java.lang.String.format; private void checkComplianceOfCommonChunk() { final CommonChunk chunk = aiff.getCommonChunk(); int physicalSizeOfDataPortion = 0; physicalSizeOfDataPortion += chunk.getNumChannels().getSize(); physicalSizeOfDataPortion += chunk.getNumSampleFrames().getSize(); physicalSizeOfDataPortion += chunk.getSampleSize().getSize(); physicalSizeOfDataPortion += chunk.getSampleRate().getSize(); if (codecAndDescriptionArePresent(chunk.getCodec(), chunk.getDescription())) { physicalSizeOfDataPortion += chunk.getCodec().getSize(); physicalSizeOfDataPortion += chunk.getDescription().length; } int expectedChunkSize = physicalSizeOfDataPortion % 2 == 0 ? physicalSizeOfDataPortion : physicalSizeOfDataPortion + 1; int expectedPhysicalSize = physicalSizeOfDataPortion + 8; if (expectedPhysicalSize % 2 == 1) { expectedPhysicalSize++; } checkChunkSizes(chunk, expectedChunkSize, expectedPhysicalSize); } private void checkChunkSizes(Chunk chunk, int expectedChunkSize, int expectedPhysicalSize) { final String message = format("chunkSize in the %s chunk is %s, was expecting %s", chunk.getChunkID().toString(), chunk.getChunkSize().toInt(), expectedChunkSize);
check(chunk.getChunkSize().equals(SignedLong.fromInt(expectedChunkSize)), message);
operator1/op1
op1/src/main/java/com/op1/util/ComplianceCheck.java
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // }
import com.op1.aiff.*; import com.op1.iff.Chunk; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import java.util.ArrayList; import java.util.List; import static com.op1.aiff.ChunkType.APPLICATION; import static java.lang.String.format;
if (codecAndDescriptionArePresent(chunk.getCodec(), chunk.getDescription())) { physicalSizeOfDataPortion += chunk.getCodec().getSize(); physicalSizeOfDataPortion += chunk.getDescription().length; } int expectedChunkSize = physicalSizeOfDataPortion % 2 == 0 ? physicalSizeOfDataPortion : physicalSizeOfDataPortion + 1; int expectedPhysicalSize = physicalSizeOfDataPortion + 8; if (expectedPhysicalSize % 2 == 1) { expectedPhysicalSize++; } checkChunkSizes(chunk, expectedChunkSize, expectedPhysicalSize); } private void checkChunkSizes(Chunk chunk, int expectedChunkSize, int expectedPhysicalSize) { final String message = format("chunkSize in the %s chunk is %s, was expecting %s", chunk.getChunkID().toString(), chunk.getChunkSize().toInt(), expectedChunkSize); check(chunk.getChunkSize().equals(SignedLong.fromInt(expectedChunkSize)), message); final String physicalSizeMessage = String.format("physical size of %s chunk is %s, was expecting %s", chunk.getChunkID().toString(), chunk.getPhysicalSize(), expectedPhysicalSize); check(chunk.getPhysicalSize() == expectedPhysicalSize, physicalSizeMessage); final String evenNumberMessage = String.format("physical size of %s chunk is %s, was expecting an even number", chunk.getChunkID().toString(), chunk.getPhysicalSize()); check(chunk.getPhysicalSize() % 2 == 0, evenNumberMessage); }
// Path: op1/src/main/java/com/op1/iff/Chunk.java // public interface Chunk { // // /** // * Returns the ID of this chunk. // */ // ID getChunkID(); // // /** // * Returns the size in bytes of the data portion of the chunk. The count does not include the 8 bytes used by the // * chunk ID and chunk size. Also, please note, when the data portion of a chunk contains an odd number of bytes, // * chunk readers should expect to read an extra pad byte (0) which is also not included in the chunk size count. // */ // SignedLong getChunkSize(); // // /** // * Returns the actual number of bytes used to represent this Chunk. This should be equal to the value returned by // * getChunkSize() + 8 [+1 if getChunkSize() is odd]. // */ // int getPhysicalSize(); // } // // Path: op1/src/main/java/com/op1/iff/types/ID.java // public class ID extends DataType { // // private final String name; // // public ID(byte[] bytes) { // // TODO: ahem, validation? // super(bytes, 4); // this.name = new String(bytes); // } // // public static ID valueOf(String s) { // return new ID(s.getBytes()); // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return getName(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final ID id = (ID) o; // // return Arrays.equals(bytes, id.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // // Path: op1/src/main/java/com/op1/iff/types/SignedLong.java // public class SignedLong extends DataType { // // // public SignedLong(byte[] bytes) { // super(bytes, 4); // } // // public int toInt() { // return ByteBuffer.wrap(bytes).getInt(); // } // // public static SignedLong fromInt(int i) { // return new SignedLong(ByteBuffer.allocate(4).putInt(i).array()); // } // // @Override // public String toString() { // return String.valueOf(toInt()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final SignedLong that = (SignedLong) o; // // return Arrays.equals(bytes, that.bytes); // // } // // @Override // public int hashCode() { // return Arrays.hashCode(bytes); // } // } // Path: op1/src/main/java/com/op1/util/ComplianceCheck.java import com.op1.aiff.*; import com.op1.iff.Chunk; import com.op1.iff.types.ID; import com.op1.iff.types.SignedLong; import java.util.ArrayList; import java.util.List; import static com.op1.aiff.ChunkType.APPLICATION; import static java.lang.String.format; if (codecAndDescriptionArePresent(chunk.getCodec(), chunk.getDescription())) { physicalSizeOfDataPortion += chunk.getCodec().getSize(); physicalSizeOfDataPortion += chunk.getDescription().length; } int expectedChunkSize = physicalSizeOfDataPortion % 2 == 0 ? physicalSizeOfDataPortion : physicalSizeOfDataPortion + 1; int expectedPhysicalSize = physicalSizeOfDataPortion + 8; if (expectedPhysicalSize % 2 == 1) { expectedPhysicalSize++; } checkChunkSizes(chunk, expectedChunkSize, expectedPhysicalSize); } private void checkChunkSizes(Chunk chunk, int expectedChunkSize, int expectedPhysicalSize) { final String message = format("chunkSize in the %s chunk is %s, was expecting %s", chunk.getChunkID().toString(), chunk.getChunkSize().toInt(), expectedChunkSize); check(chunk.getChunkSize().equals(SignedLong.fromInt(expectedChunkSize)), message); final String physicalSizeMessage = String.format("physical size of %s chunk is %s, was expecting %s", chunk.getChunkID().toString(), chunk.getPhysicalSize(), expectedPhysicalSize); check(chunk.getPhysicalSize() == expectedPhysicalSize, physicalSizeMessage); final String evenNumberMessage = String.format("physical size of %s chunk is %s, was expecting an even number", chunk.getChunkID().toString(), chunk.getPhysicalSize()); check(chunk.getPhysicalSize() % 2 == 0, evenNumberMessage); }
private boolean codecAndDescriptionArePresent(ID codec, byte[] description) {
nextgis/android_maplib
src/main/java/com/nextgis/maplib/util/AccountUtil.java
// Path: src/main/java/com/nextgis/maplib/api/IGISApplication.java // public interface IGISApplication // { // /** // * @return A MapBase or any inherited classes or null if not created in application // */ // MapBase getMap(); // // /** // * @return A authority for sync purposes or empty string if not sync anything // */ // String getAuthority(); // // /** // * Add account to android account storage // * @param name Account name (must be uniq) // * @param url NextGIS Web Server URL // * @param login User login // * @param password User password // * @param token A token returned from NextGIS Web Server (may be empty string) // * @return true on success or false // */ // boolean addAccount(String name, String url, String login, String password, String token); // // /** // * Update account information // * @param name Account name (the account must be exist) // * @param key The account key to change (i.e. URL) // * @param value The new value for key // */ // void setUserData(String name, String key, String value); // // /** // * Change password for account // * @param name Account name (the account must be exist) // * @param value New password // */ // void setPassword(String name,String value); // // /** // * @param accountName Account name // * @return Account by its name // */ // Account getAccount(String accountName); // // /** // * Remove an account // * @param account Account to remove // * @return An @see AccountManagerFuture which resolves to a Boolean, true if the account has been successfully removed // */ // AccountManagerFuture<Boolean> removeAccount(Account account); // // /** // * @param account Account object // * @return Account URL // */ // String getAccountUrl(Account account); // // /** // * Return some account data // * @param account account object // * @param key key to return // * @return value in user key - value map // */ // String getAccountUserData(Account account, String key); // // /** // * @param account Account object // * @return Account login // */ // String getAccountLogin(Account account); // // /** // * @param account Account object // * @return Account password // */ // String getAccountPassword(Account account); // // /** // * @return A GpsEventSource or null if not needed or created in application // */ // GpsEventSource getGpsEventSource(); // // /** // * Show settings Activity or nothing // */ // void showSettings(String setting); // // /** // * Send target event to analytics // */ // void sendEvent(String category, String action, String label); // // /** // * Send screen hit to analytics // */ // void sendScreen(String name); // // /** // * Get accounts authenticator type // */ // String getAccountsType(); // // /** // * Get LayerFactory // */ // LayerFactory getLayerFactory(); // }
import android.accounts.Account; import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.Context; import android.content.SyncInfo; import android.os.Build; import android.util.Base64; import com.nextgis.maplib.api.IGISApplication; import org.json.JSONException; import org.json.JSONObject; import java.io.File; import java.io.IOException; import java.security.KeyFactory; import java.security.PublicKey; import java.security.Signature; import java.security.spec.X509EncodedKeySpec; import static com.nextgis.maplib.util.Constants.JSON_END_DATE_KEY; import static com.nextgis.maplib.util.Constants.JSON_SIGNATURE_KEY; import static com.nextgis.maplib.util.Constants.JSON_START_DATE_KEY; import static com.nextgis.maplib.util.Constants.JSON_SUPPORTED_KEY; import static com.nextgis.maplib.util.Constants.JSON_USER_ID_KEY; import static com.nextgis.maplib.util.Constants.SUPPORT;
"06z5a0sd3NDbS++GMCJstcKxkzk5KLQljAJ85Jciiuy2vv14WU621ves8S9cMISO\n" + "HwIDAQAB"; byte[] keyBytes = Base64.decode(key.getBytes("UTF-8"), Base64.DEFAULT); X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); PublicKey publicKey = keyFactory.generatePublic(spec); // verify signature Signature signCheck = Signature.getInstance("SHA256withRSA"); signCheck.initVerify(publicKey); signCheck.update(data.getBytes("UTF-8")); byte[] sigBytes = Base64.decode(signature, Base64.DEFAULT); return signCheck.verify(sigBytes); } catch (Exception e) { return false; } } public static boolean isSyncActive(Account account, String authority) { return isSyncActiveHoneycomb(account, authority); } public static boolean isSyncActiveHoneycomb(Account account, String authority) { for (SyncInfo syncInfo : ContentResolver.getCurrentSyncs()) { if (syncInfo.account.equals(account) && syncInfo.authority.equals(authority)) { return true; } } return false; } public static AccountData getAccountData(Context context, String accountName) throws IllegalStateException {
// Path: src/main/java/com/nextgis/maplib/api/IGISApplication.java // public interface IGISApplication // { // /** // * @return A MapBase or any inherited classes or null if not created in application // */ // MapBase getMap(); // // /** // * @return A authority for sync purposes or empty string if not sync anything // */ // String getAuthority(); // // /** // * Add account to android account storage // * @param name Account name (must be uniq) // * @param url NextGIS Web Server URL // * @param login User login // * @param password User password // * @param token A token returned from NextGIS Web Server (may be empty string) // * @return true on success or false // */ // boolean addAccount(String name, String url, String login, String password, String token); // // /** // * Update account information // * @param name Account name (the account must be exist) // * @param key The account key to change (i.e. URL) // * @param value The new value for key // */ // void setUserData(String name, String key, String value); // // /** // * Change password for account // * @param name Account name (the account must be exist) // * @param value New password // */ // void setPassword(String name,String value); // // /** // * @param accountName Account name // * @return Account by its name // */ // Account getAccount(String accountName); // // /** // * Remove an account // * @param account Account to remove // * @return An @see AccountManagerFuture which resolves to a Boolean, true if the account has been successfully removed // */ // AccountManagerFuture<Boolean> removeAccount(Account account); // // /** // * @param account Account object // * @return Account URL // */ // String getAccountUrl(Account account); // // /** // * Return some account data // * @param account account object // * @param key key to return // * @return value in user key - value map // */ // String getAccountUserData(Account account, String key); // // /** // * @param account Account object // * @return Account login // */ // String getAccountLogin(Account account); // // /** // * @param account Account object // * @return Account password // */ // String getAccountPassword(Account account); // // /** // * @return A GpsEventSource or null if not needed or created in application // */ // GpsEventSource getGpsEventSource(); // // /** // * Show settings Activity or nothing // */ // void showSettings(String setting); // // /** // * Send target event to analytics // */ // void sendEvent(String category, String action, String label); // // /** // * Send screen hit to analytics // */ // void sendScreen(String name); // // /** // * Get accounts authenticator type // */ // String getAccountsType(); // // /** // * Get LayerFactory // */ // LayerFactory getLayerFactory(); // } // Path: src/main/java/com/nextgis/maplib/util/AccountUtil.java import android.accounts.Account; import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.Context; import android.content.SyncInfo; import android.os.Build; import android.util.Base64; import com.nextgis.maplib.api.IGISApplication; import org.json.JSONException; import org.json.JSONObject; import java.io.File; import java.io.IOException; import java.security.KeyFactory; import java.security.PublicKey; import java.security.Signature; import java.security.spec.X509EncodedKeySpec; import static com.nextgis.maplib.util.Constants.JSON_END_DATE_KEY; import static com.nextgis.maplib.util.Constants.JSON_SIGNATURE_KEY; import static com.nextgis.maplib.util.Constants.JSON_START_DATE_KEY; import static com.nextgis.maplib.util.Constants.JSON_SUPPORTED_KEY; import static com.nextgis.maplib.util.Constants.JSON_USER_ID_KEY; import static com.nextgis.maplib.util.Constants.SUPPORT; "06z5a0sd3NDbS++GMCJstcKxkzk5KLQljAJ85Jciiuy2vv14WU621ves8S9cMISO\n" + "HwIDAQAB"; byte[] keyBytes = Base64.decode(key.getBytes("UTF-8"), Base64.DEFAULT); X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); PublicKey publicKey = keyFactory.generatePublic(spec); // verify signature Signature signCheck = Signature.getInstance("SHA256withRSA"); signCheck.initVerify(publicKey); signCheck.update(data.getBytes("UTF-8")); byte[] sigBytes = Base64.decode(signature, Base64.DEFAULT); return signCheck.verify(sigBytes); } catch (Exception e) { return false; } } public static boolean isSyncActive(Account account, String authority) { return isSyncActiveHoneycomb(account, authority); } public static boolean isSyncActiveHoneycomb(Account account, String authority) { for (SyncInfo syncInfo : ContentResolver.getCurrentSyncs()) { if (syncInfo.account.equals(account) && syncInfo.authority.equals(authority)) { return true; } } return false; } public static AccountData getAccountData(Context context, String accountName) throws IllegalStateException {
IGISApplication app = (IGISApplication) context.getApplicationContext();
nextgis/android_maplib
src/main/java/com/nextgis/maplib/display/RuleFeatureRenderer.java
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/api/IStyleRule.java // public interface IStyleRule // { // /** // * Set style parameters // * @param style New style // * @param featureId The feature identifier to set style // */ // void setStyleParams( // Style style, // long featureId); // } // // Path: src/main/java/com/nextgis/maplib/map/Layer.java // public class Layer extends Table // implements ILayerView, IRenderer // { // protected boolean mIsVisible; // protected float mMaxZoom; // protected float mMinZoom; // protected IRenderer mRenderer; // protected GeoEnvelope mExtents; // // // public Layer( // Context context, // File path) // { // super(context, path); // mExtents = new GeoEnvelope(); // } // // @Override // public void runDraw(GISDisplay display) // { // if (mRenderer != null) { // mRenderer.runDraw(display); // //onDrawFinished(this.getId(), 1.0f); // } // } // // @Override // public void cancelDraw() // { // if (mRenderer != null) { // mRenderer.cancelDraw(); // } // } // // @Override // public boolean isVisible() // { // return mIsVisible; // } // // @Override // public void setVisible(boolean visible) // { // mIsVisible = visible; // notifyLayerChanged(); // } // // @Override // public float getMaxZoom() // { // return Float.compare(mMaxZoom, mMinZoom) == 0 ? GeoConstants.DEFAULT_MAX_ZOOM : mMaxZoom; // } // // @Override // public void setMaxZoom(float maxZoom) // { // mMaxZoom = maxZoom; // } // // @Override // public float getMinZoom() // { // return mMinZoom; // } // // @Override // public void setMinZoom(float minZoom) // { // mMinZoom = minZoom; // } // // @Override // public JSONObject toJSON() // throws JSONException // { // JSONObject rootConfig = super.toJSON(); // rootConfig.put(JSON_MAXLEVEL_KEY, getMaxZoom()); // rootConfig.put(JSON_MINLEVEL_KEY, getMinZoom()); // rootConfig.put(JSON_VISIBILITY_KEY, isVisible()); // return rootConfig; // } // // @Override // public void fromJSON(JSONObject jsonObject) // throws JSONException // { // super.fromJSON(jsonObject); // if (jsonObject.has(JSON_MAXLEVEL_KEY)) { // mMaxZoom = (float) jsonObject.getDouble(JSON_MAXLEVEL_KEY); // } else { // mMaxZoom = GeoConstants.DEFAULT_MAX_ZOOM; // } // if (jsonObject.has(JSON_MINLEVEL_KEY)) { // mMinZoom = (float) jsonObject.getDouble(JSON_MINLEVEL_KEY); // } else { // mMinZoom = GeoConstants.DEFAULT_MIN_ZOOM; // } // // mIsVisible = jsonObject.getBoolean(JSON_VISIBILITY_KEY); // // if(Constants.DEBUG_MODE){ // Log.d(Constants.TAG, "Layer " + getName() + " is visible " + mIsVisible); // Log.d(Constants.TAG, "Layer " + getName() + " zoom limits from " + mMinZoom + " to " + mMaxZoom); // } // } // // @Override // public void onDrawFinished( // int id, // float percent) // { // if (mParent != null && mParent instanceof ILayerView) { // ILayerView layerView = (ILayerView) mParent; // layerView.onDrawFinished(id, percent); // } // } // // @Override // public void setViewSize( // int w, // int h) // { // // } // // @Override // public GeoEnvelope getExtents() // { // return mExtents; // } // // @Override // public IRenderer getRenderer() // { // return mRenderer; // } // // @Override // public void setRenderer(IRenderer renderer) { // mRenderer = renderer; // } // }
import static com.nextgis.maplib.util.Constants.JSON_STYLE_RULE_KEY; import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.api.IStyleRule; import com.nextgis.maplib.map.Layer; import org.json.JSONException; import org.json.JSONObject; import static com.nextgis.maplib.util.Constants.JSON_NAME_KEY;
Style styleClone = mStyle.clone(); mStyleRule.setStyleParams(styleClone, featureId); applyField(styleClone, featureId); return styleClone; } catch (CloneNotSupportedException e) { e.printStackTrace(); return super.getStyle(featureId); } } public IStyleRule getStyleRule() { return mStyleRule; } public void setStyleRule(IStyleRule styleRule) { mStyleRule = styleRule; } @Override public JSONObject toJSON() throws JSONException { JSONObject rootJsonObject = super.toJSON(); rootJsonObject.put(JSON_NAME_KEY, "RuleFeatureRenderer");
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/api/IStyleRule.java // public interface IStyleRule // { // /** // * Set style parameters // * @param style New style // * @param featureId The feature identifier to set style // */ // void setStyleParams( // Style style, // long featureId); // } // // Path: src/main/java/com/nextgis/maplib/map/Layer.java // public class Layer extends Table // implements ILayerView, IRenderer // { // protected boolean mIsVisible; // protected float mMaxZoom; // protected float mMinZoom; // protected IRenderer mRenderer; // protected GeoEnvelope mExtents; // // // public Layer( // Context context, // File path) // { // super(context, path); // mExtents = new GeoEnvelope(); // } // // @Override // public void runDraw(GISDisplay display) // { // if (mRenderer != null) { // mRenderer.runDraw(display); // //onDrawFinished(this.getId(), 1.0f); // } // } // // @Override // public void cancelDraw() // { // if (mRenderer != null) { // mRenderer.cancelDraw(); // } // } // // @Override // public boolean isVisible() // { // return mIsVisible; // } // // @Override // public void setVisible(boolean visible) // { // mIsVisible = visible; // notifyLayerChanged(); // } // // @Override // public float getMaxZoom() // { // return Float.compare(mMaxZoom, mMinZoom) == 0 ? GeoConstants.DEFAULT_MAX_ZOOM : mMaxZoom; // } // // @Override // public void setMaxZoom(float maxZoom) // { // mMaxZoom = maxZoom; // } // // @Override // public float getMinZoom() // { // return mMinZoom; // } // // @Override // public void setMinZoom(float minZoom) // { // mMinZoom = minZoom; // } // // @Override // public JSONObject toJSON() // throws JSONException // { // JSONObject rootConfig = super.toJSON(); // rootConfig.put(JSON_MAXLEVEL_KEY, getMaxZoom()); // rootConfig.put(JSON_MINLEVEL_KEY, getMinZoom()); // rootConfig.put(JSON_VISIBILITY_KEY, isVisible()); // return rootConfig; // } // // @Override // public void fromJSON(JSONObject jsonObject) // throws JSONException // { // super.fromJSON(jsonObject); // if (jsonObject.has(JSON_MAXLEVEL_KEY)) { // mMaxZoom = (float) jsonObject.getDouble(JSON_MAXLEVEL_KEY); // } else { // mMaxZoom = GeoConstants.DEFAULT_MAX_ZOOM; // } // if (jsonObject.has(JSON_MINLEVEL_KEY)) { // mMinZoom = (float) jsonObject.getDouble(JSON_MINLEVEL_KEY); // } else { // mMinZoom = GeoConstants.DEFAULT_MIN_ZOOM; // } // // mIsVisible = jsonObject.getBoolean(JSON_VISIBILITY_KEY); // // if(Constants.DEBUG_MODE){ // Log.d(Constants.TAG, "Layer " + getName() + " is visible " + mIsVisible); // Log.d(Constants.TAG, "Layer " + getName() + " zoom limits from " + mMinZoom + " to " + mMaxZoom); // } // } // // @Override // public void onDrawFinished( // int id, // float percent) // { // if (mParent != null && mParent instanceof ILayerView) { // ILayerView layerView = (ILayerView) mParent; // layerView.onDrawFinished(id, percent); // } // } // // @Override // public void setViewSize( // int w, // int h) // { // // } // // @Override // public GeoEnvelope getExtents() // { // return mExtents; // } // // @Override // public IRenderer getRenderer() // { // return mRenderer; // } // // @Override // public void setRenderer(IRenderer renderer) { // mRenderer = renderer; // } // } // Path: src/main/java/com/nextgis/maplib/display/RuleFeatureRenderer.java import static com.nextgis.maplib.util.Constants.JSON_STYLE_RULE_KEY; import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.api.IStyleRule; import com.nextgis.maplib.map.Layer; import org.json.JSONException; import org.json.JSONObject; import static com.nextgis.maplib.util.Constants.JSON_NAME_KEY; Style styleClone = mStyle.clone(); mStyleRule.setStyleParams(styleClone, featureId); applyField(styleClone, featureId); return styleClone; } catch (CloneNotSupportedException e) { e.printStackTrace(); return super.getStyle(featureId); } } public IStyleRule getStyleRule() { return mStyleRule; } public void setStyleRule(IStyleRule styleRule) { mStyleRule = styleRule; } @Override public JSONObject toJSON() throws JSONException { JSONObject rootJsonObject = super.toJSON(); rootJsonObject.put(JSON_NAME_KEY, "RuleFeatureRenderer");
if (mStyleRule instanceof IJSONStore)
nextgis/android_maplib
src/main/java/com/nextgis/maplib/datasource/Geo.java
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // }
import com.nextgis.maplib.util.GeoConstants;
retPt.mX = wgs84ToMercatorSphereX(point.mX); retPt.mY = wgs84ToMercatorSphereY(point.mY); return retPt; } public static double wgs84ToMercatorSphereX(final double x) { return mEarthMajorRadius * Math.toRadians(x); } public static double wgs84ToMercatorSphereY(final double y) { return mEarthMajorRadius * Math.log(Math.tan(Math.PI / 4 + Math.toRadians(y) / 2)); } public static void wgs84ToMercatorSphere(GeoPoint point) { point.mX = wgs84ToMercatorSphereX(point.mX); point.mY = wgs84ToMercatorSphereY(point.mY); } public static boolean isGeometryTypeSame( final int type1, final int type2) { return type1 == type2 ||
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // } // Path: src/main/java/com/nextgis/maplib/datasource/Geo.java import com.nextgis.maplib.util.GeoConstants; retPt.mX = wgs84ToMercatorSphereX(point.mX); retPt.mY = wgs84ToMercatorSphereY(point.mY); return retPt; } public static double wgs84ToMercatorSphereX(final double x) { return mEarthMajorRadius * Math.toRadians(x); } public static double wgs84ToMercatorSphereY(final double y) { return mEarthMajorRadius * Math.log(Math.tan(Math.PI / 4 + Math.toRadians(y) / 2)); } public static void wgs84ToMercatorSphere(GeoPoint point) { point.mX = wgs84ToMercatorSphereX(point.mX); point.mY = wgs84ToMercatorSphereY(point.mY); } public static boolean isGeometryTypeSame( final int type1, final int type2) { return type1 == type2 ||
(type1 <= GeoConstants.GTMultiPolygon && type2 <= GeoConstants.GTMultiPolygon &&
nextgis/android_maplib
src/main/java/com/nextgis/maplib/api/IStyleRule.java
// Path: src/main/java/com/nextgis/maplib/display/Style.java // public abstract class Style implements IJSONStore, Cloneable { // protected float mWidth; // protected int mColor; // protected int mOutColor; // protected int mOuterAlpha = 255; // protected int mInnerAlpha = 255; // // public Style() { // mWidth = 3; // } // // public Style clone() throws CloneNotSupportedException { // Style obj = (Style) super.clone(); // obj.mWidth = mWidth; // obj.mColor = mColor; // obj.mOutColor = mOutColor; // obj.mInnerAlpha = mInnerAlpha; // obj.mOuterAlpha = mOuterAlpha; // return obj; // } // // public int getColor() { // return mColor; // } // // public void setColor(int color) { // mColor = color; // } // // public int getOutColor() { // return mOutColor; // } // // public void setOutColor(int outColor) { // mOutColor = outColor; // } // // public float getWidth() { // return mWidth; // } // // public void setWidth(float width) { // mWidth = width; // } // // public Style(final int color, int outColor) { // this(); // mColor = color; // mOutColor = outColor; // } // // public abstract void onDraw(GeoGeometry geoGeometry, GISDisplay display); // // @Override // public JSONObject toJSON() throws JSONException { // JSONObject rootConfig = new JSONObject(); // rootConfig.put(JSON_WIDTH_KEY, mWidth); // rootConfig.put(JSON_COLOR_KEY, mColor); // rootConfig.put(JSON_OUTCOLOR_KEY, mOutColor); // rootConfig.put(JSON_ALPHA_KEY, mInnerAlpha); // rootConfig.put(JSON_OUTALPHA_KEY, mOuterAlpha); // return rootConfig; // } // // @Override // public void fromJSON(JSONObject jsonObject) throws JSONException { // mWidth = (float) jsonObject.optDouble(JSON_WIDTH_KEY, 3); // mColor = jsonObject.getInt(JSON_COLOR_KEY); // mOutColor = jsonObject.optInt(JSON_OUTCOLOR_KEY, mColor); // mInnerAlpha = jsonObject.optInt(JSON_ALPHA_KEY, 255); // mOuterAlpha = jsonObject.optInt(JSON_OUTALPHA_KEY, 255); // } // // public int getAlpha() { // return mInnerAlpha; // } // // public void setAlpha(int alpha) { // mInnerAlpha = alpha; // } // // public int getOutAlpha() { // return mOuterAlpha; // } // // public void setOutAlpha(int alpha) { // mOuterAlpha = alpha; // } // }
import com.nextgis.maplib.display.Style;
/* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.api; public interface IStyleRule { /** * Set style parameters * @param style New style * @param featureId The feature identifier to set style */ void setStyleParams(
// Path: src/main/java/com/nextgis/maplib/display/Style.java // public abstract class Style implements IJSONStore, Cloneable { // protected float mWidth; // protected int mColor; // protected int mOutColor; // protected int mOuterAlpha = 255; // protected int mInnerAlpha = 255; // // public Style() { // mWidth = 3; // } // // public Style clone() throws CloneNotSupportedException { // Style obj = (Style) super.clone(); // obj.mWidth = mWidth; // obj.mColor = mColor; // obj.mOutColor = mOutColor; // obj.mInnerAlpha = mInnerAlpha; // obj.mOuterAlpha = mOuterAlpha; // return obj; // } // // public int getColor() { // return mColor; // } // // public void setColor(int color) { // mColor = color; // } // // public int getOutColor() { // return mOutColor; // } // // public void setOutColor(int outColor) { // mOutColor = outColor; // } // // public float getWidth() { // return mWidth; // } // // public void setWidth(float width) { // mWidth = width; // } // // public Style(final int color, int outColor) { // this(); // mColor = color; // mOutColor = outColor; // } // // public abstract void onDraw(GeoGeometry geoGeometry, GISDisplay display); // // @Override // public JSONObject toJSON() throws JSONException { // JSONObject rootConfig = new JSONObject(); // rootConfig.put(JSON_WIDTH_KEY, mWidth); // rootConfig.put(JSON_COLOR_KEY, mColor); // rootConfig.put(JSON_OUTCOLOR_KEY, mOutColor); // rootConfig.put(JSON_ALPHA_KEY, mInnerAlpha); // rootConfig.put(JSON_OUTALPHA_KEY, mOuterAlpha); // return rootConfig; // } // // @Override // public void fromJSON(JSONObject jsonObject) throws JSONException { // mWidth = (float) jsonObject.optDouble(JSON_WIDTH_KEY, 3); // mColor = jsonObject.getInt(JSON_COLOR_KEY); // mOutColor = jsonObject.optInt(JSON_OUTCOLOR_KEY, mColor); // mInnerAlpha = jsonObject.optInt(JSON_ALPHA_KEY, 255); // mOuterAlpha = jsonObject.optInt(JSON_OUTALPHA_KEY, 255); // } // // public int getAlpha() { // return mInnerAlpha; // } // // public void setAlpha(int alpha) { // mInnerAlpha = alpha; // } // // public int getOutAlpha() { // return mOuterAlpha; // } // // public void setOutAlpha(int alpha) { // mOuterAlpha = alpha; // } // } // Path: src/main/java/com/nextgis/maplib/api/IStyleRule.java import com.nextgis.maplib.display.Style; /* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.api; public interface IStyleRule { /** * Set style parameters * @param style New style * @param featureId The feature identifier to set style */ void setStyleParams(
Style style,
nextgis/android_maplib
src/main/java/com/nextgis/maplib/datasource/GeoPoint.java
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // }
import java.io.DataOutputStream; import java.io.IOException; import java.util.Locale; import static com.nextgis.maplib.util.GeoConstants.CRS_WEB_MERCATOR; import static com.nextgis.maplib.util.GeoConstants.CRS_WGS84; import static com.nextgis.maplib.util.GeoConstants.GTPoint; import static com.nextgis.maplib.util.GeoConstants.MERCATOR_MAX; import static com.nextgis.maplib.util.GeoConstants.WGS_LAT_MAX; import static com.nextgis.maplib.util.GeoConstants.WGS_LONG_MAX; import android.util.JsonReader; import com.nextgis.maplib.util.GeoConstants; import org.json.JSONArray; import org.json.JSONException; import java.io.DataInputStream;
Geo.mercatorToWgs84Sphere(this); return super.rawProject(toCrs); default: return false; } } @Override public GeoEnvelope getEnvelope() { return new GeoEnvelope(mX, mX, mY, mY); } @Override public JSONArray coordinatesToJSON() throws JSONException { JSONArray coordinates = new JSONArray(); coordinates.put(mX); coordinates.put(mY); return coordinates; } @Override public final int getType() {
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // } // Path: src/main/java/com/nextgis/maplib/datasource/GeoPoint.java import java.io.DataOutputStream; import java.io.IOException; import java.util.Locale; import static com.nextgis.maplib.util.GeoConstants.CRS_WEB_MERCATOR; import static com.nextgis.maplib.util.GeoConstants.CRS_WGS84; import static com.nextgis.maplib.util.GeoConstants.GTPoint; import static com.nextgis.maplib.util.GeoConstants.MERCATOR_MAX; import static com.nextgis.maplib.util.GeoConstants.WGS_LAT_MAX; import static com.nextgis.maplib.util.GeoConstants.WGS_LONG_MAX; import android.util.JsonReader; import com.nextgis.maplib.util.GeoConstants; import org.json.JSONArray; import org.json.JSONException; import java.io.DataInputStream; Geo.mercatorToWgs84Sphere(this); return super.rawProject(toCrs); default: return false; } } @Override public GeoEnvelope getEnvelope() { return new GeoEnvelope(mX, mX, mY, mY); } @Override public JSONArray coordinatesToJSON() throws JSONException { JSONArray coordinates = new JSONArray(); coordinates.put(mX); coordinates.put(mY); return coordinates; } @Override public final int getType() {
return GeoConstants.GTPoint;
nextgis/android_maplib
src/main/java/com/nextgis/maplib/datasource/GeometryPlainList.java
// Path: src/main/java/com/nextgis/maplib/api/IGeometryCache.java // public interface IGeometryCache { // // /** // * Check if item with specified id is exist in cache // * @param featureId Feature id // * @return true if item is exist or false // */ // boolean isItemExist(long featureId); // // /** // * Add item to cache // * @param id Feature identificator // * @param envelope Envelope // */ // IGeometryCacheItem addItem(long id, GeoEnvelope envelope); // // /** // * Return cache item by feature identificator // * @param featureId Feature identificator // * @return Cache item // */ // IGeometryCacheItem getItem(long featureId); // // /** // * Remove item from cache // * @param featureId Feature id of cache item // * @return removed item or null // */ // IGeometryCacheItem removeItem(long featureId); // // /** // * Return count of items // * @return count of items // */ // int size(); // // /** // * Remove all items from cache // */ // void clear(); // // /** // * Search items intersected provided envelope // * @param extent Envelope to search // * @return List of items intersected provided envelope // */ // List<IGeometryCacheItem> search(GeoEnvelope extent); // // /** // * Get all items // * @return List of all items // */ // List<IGeometryCacheItem> getAll(); // // void changeId(long oldFeatureId, long newFeatureId); // // void save(File path); // // void load(File path); // } // // Path: src/main/java/com/nextgis/maplib/api/IGeometryCacheItem.java // public interface IGeometryCacheItem { // /** // * // * @return Return an envelope // */ // GeoEnvelope getEnvelope(); // // /** // * // * @return A feature identificator connected with this cache item // */ // long getFeatureId(); // // // /** // * Set a eature identificator connected with this cache item // * @param id Feature identificator // */ // void setFeatureId(long id); // }
import com.nextgis.maplib.api.IGeometryCache; import com.nextgis.maplib.api.IGeometryCacheItem; import java.io.File; import java.util.Iterator; import java.util.LinkedList; import java.util.List;
/* * Project: Forest violations * Purpose: Mobile application for registering facts of the forest violations. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * ***************************************************************************** * Copyright (c) 2015-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.datasource; /** * Geometry cache based on plain list (ArrayList) */ public class GeometryPlainList implements IGeometryCache { protected List<VectorCacheItem> mVectorCacheItems; public GeometryPlainList() { mVectorCacheItems = new LinkedList<>(); } @Override public boolean isItemExist(long featureId) { for(VectorCacheItem item : mVectorCacheItems){ if(item.getFeatureId() == featureId) return true; } return false; } @Override
// Path: src/main/java/com/nextgis/maplib/api/IGeometryCache.java // public interface IGeometryCache { // // /** // * Check if item with specified id is exist in cache // * @param featureId Feature id // * @return true if item is exist or false // */ // boolean isItemExist(long featureId); // // /** // * Add item to cache // * @param id Feature identificator // * @param envelope Envelope // */ // IGeometryCacheItem addItem(long id, GeoEnvelope envelope); // // /** // * Return cache item by feature identificator // * @param featureId Feature identificator // * @return Cache item // */ // IGeometryCacheItem getItem(long featureId); // // /** // * Remove item from cache // * @param featureId Feature id of cache item // * @return removed item or null // */ // IGeometryCacheItem removeItem(long featureId); // // /** // * Return count of items // * @return count of items // */ // int size(); // // /** // * Remove all items from cache // */ // void clear(); // // /** // * Search items intersected provided envelope // * @param extent Envelope to search // * @return List of items intersected provided envelope // */ // List<IGeometryCacheItem> search(GeoEnvelope extent); // // /** // * Get all items // * @return List of all items // */ // List<IGeometryCacheItem> getAll(); // // void changeId(long oldFeatureId, long newFeatureId); // // void save(File path); // // void load(File path); // } // // Path: src/main/java/com/nextgis/maplib/api/IGeometryCacheItem.java // public interface IGeometryCacheItem { // /** // * // * @return Return an envelope // */ // GeoEnvelope getEnvelope(); // // /** // * // * @return A feature identificator connected with this cache item // */ // long getFeatureId(); // // // /** // * Set a eature identificator connected with this cache item // * @param id Feature identificator // */ // void setFeatureId(long id); // } // Path: src/main/java/com/nextgis/maplib/datasource/GeometryPlainList.java import com.nextgis.maplib.api.IGeometryCache; import com.nextgis.maplib.api.IGeometryCacheItem; import java.io.File; import java.util.Iterator; import java.util.LinkedList; import java.util.List; /* * Project: Forest violations * Purpose: Mobile application for registering facts of the forest violations. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * ***************************************************************************** * Copyright (c) 2015-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.datasource; /** * Geometry cache based on plain list (ArrayList) */ public class GeometryPlainList implements IGeometryCache { protected List<VectorCacheItem> mVectorCacheItems; public GeometryPlainList() { mVectorCacheItems = new LinkedList<>(); } @Override public boolean isItemExist(long featureId) { for(VectorCacheItem item : mVectorCacheItems){ if(item.getFeatureId() == featureId) return true; } return false; } @Override
public IGeometryCacheItem addItem(long id, GeoEnvelope envelope) {
nextgis/android_maplib
src/main/java/com/nextgis/maplib/datasource/DatabaseHelper.java
// Path: src/main/java/com/nextgis/maplib/map/MapBase.java // public class MapBase // extends LayerGroup // { // protected int mNewId; // protected static MapBase mInstance = null; // protected String mFileName; // private boolean mDirty; // // public MapBase( // Context context, // File path, // LayerFactory layerFactory) // { // super(context, path.getParentFile(), layerFactory); // mNewId = 0; // mId = NOT_FOUND; // mInstance = this; // mFileName = path.getName(); // } // // // /** // * The identificator generator // * // * @return new id // */ // public int getNewId() // { // return mNewId++; // } // // // @Override // protected void onLayerAdded(ILayer layer) // { // layer.setId(getNewId()); // super.onLayerAdded(layer); // } // // // public static MapBase getInstance() // { // if (mInstance == null) { // throw new IllegalArgumentException( // "Impossible to get the instance. This class must be initialized before"); // } // return mInstance; // } // // // public ILayer getLastLayer() // { // if (mLayers.size() == 0) { // return null; // } // return mLayers.get(mLayers.size() - 1); // } // // // @Override // public boolean delete() // { // for (ILayer layer : mLayers) { // layer.setParent(null); // layer.delete(); // } // // mLayers.clear(); // // return FileUtil.deleteRecursive(getFileName()); // } // // // @Override // protected File getFileName() // { // return new File(getPath(), mFileName); // } // // // public void moveTo(File newPath) // { // // if (mPath.equals(newPath)) { // return; // } // // clearLayers(); // // if (FileUtil.move(mPath, newPath)) { // //change path // mPath = newPath; // } // load(); // } // // public GeoEnvelope getFullBounds(){ // if(null != mDisplay){ // return mDisplay.getFullBounds(); // } // return new GeoEnvelope(); // } // // public GeoEnvelope getCurrentBounds() // { // if (mDisplay != null) { // return mDisplay.getBounds(); // } // return null; // } // // @Override // public void clearLayers() { // super.clearLayers(); // mNewId = 0; // } // // public void setDirty(boolean dirty) { // mDirty = dirty; // } // // public boolean isDirty() { // return mDirty; // } // } // // Path: src/main/java/com/nextgis/maplib/util/DatabaseContext.java // public class DatabaseContext // extends ContextWrapper // { // protected File mDatabasePath; // // // public DatabaseContext( // Context base, // File databasePath) // { // super(base); // mDatabasePath = databasePath; // } // // // @Override // public File getDatabasePath(String name) // { // String dbfile = mDatabasePath + File.separator + name; // if (!dbfile.endsWith(".db")) { // dbfile += ".db"; // } // // if (!mDatabasePath.exists()) { // mDatabasePath.mkdirs(); // } // // return new File(dbfile); // } // // // @Override // public SQLiteDatabase openOrCreateDatabase( // String name, // int mode, // SQLiteDatabase.CursorFactory factory, // DatabaseErrorHandler errorHandler) // { // return SQLiteDatabase.openOrCreateDatabase( // getDatabasePath(name).getAbsolutePath(), factory, errorHandler); // } // // // @Override // public SQLiteDatabase openOrCreateDatabase( // String name, // int mode, // SQLiteDatabase.CursorFactory factory) // { // SQLiteDatabase result = null; // try { // result = SQLiteDatabase.openOrCreateDatabase(getDatabasePath(name), factory); // } catch (SQLiteException e) { // e.printStackTrace(); // } // return result; // } // // public static SQLiteDatabase getDbForLayer(final VectorLayer layer){ // MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance(); // SQLiteDatabase db = map.getDatabase(false); // // speedup writing // db.rawQuery("PRAGMA synchronous=OFF", null); // //db.rawQuery("PRAGMA locking_mode=EXCLUSIVE", null); // db.rawQuery("PRAGMA journal_mode=OFF", null); // db.rawQuery("PRAGMA count_changes=OFF", null); // db.rawQuery("PRAGMA cache_size=15000", null); // // return db; // } // }
import com.nextgis.maplib.map.MapBase; import com.nextgis.maplib.util.DatabaseContext; import java.io.File; import android.annotation.TargetApi; import android.content.Context; import android.database.DatabaseErrorHandler; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.os.Build;
SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) { super( new DatabaseContext(context, dbFullName.getParentFile()), dbFullName.getName(), factory, version, errorHandler); } /** * is called whenever the app is freshly installed * @param sqLiteDatabase Database */ @Override public void onCreate(SQLiteDatabase sqLiteDatabase) { } /** * is called whenever the app is upgraded and launched and the database version is not the same * @param sqLiteDatabase Database * @param oldVersion The previous database version * @param newVersion The current database version */ @Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
// Path: src/main/java/com/nextgis/maplib/map/MapBase.java // public class MapBase // extends LayerGroup // { // protected int mNewId; // protected static MapBase mInstance = null; // protected String mFileName; // private boolean mDirty; // // public MapBase( // Context context, // File path, // LayerFactory layerFactory) // { // super(context, path.getParentFile(), layerFactory); // mNewId = 0; // mId = NOT_FOUND; // mInstance = this; // mFileName = path.getName(); // } // // // /** // * The identificator generator // * // * @return new id // */ // public int getNewId() // { // return mNewId++; // } // // // @Override // protected void onLayerAdded(ILayer layer) // { // layer.setId(getNewId()); // super.onLayerAdded(layer); // } // // // public static MapBase getInstance() // { // if (mInstance == null) { // throw new IllegalArgumentException( // "Impossible to get the instance. This class must be initialized before"); // } // return mInstance; // } // // // public ILayer getLastLayer() // { // if (mLayers.size() == 0) { // return null; // } // return mLayers.get(mLayers.size() - 1); // } // // // @Override // public boolean delete() // { // for (ILayer layer : mLayers) { // layer.setParent(null); // layer.delete(); // } // // mLayers.clear(); // // return FileUtil.deleteRecursive(getFileName()); // } // // // @Override // protected File getFileName() // { // return new File(getPath(), mFileName); // } // // // public void moveTo(File newPath) // { // // if (mPath.equals(newPath)) { // return; // } // // clearLayers(); // // if (FileUtil.move(mPath, newPath)) { // //change path // mPath = newPath; // } // load(); // } // // public GeoEnvelope getFullBounds(){ // if(null != mDisplay){ // return mDisplay.getFullBounds(); // } // return new GeoEnvelope(); // } // // public GeoEnvelope getCurrentBounds() // { // if (mDisplay != null) { // return mDisplay.getBounds(); // } // return null; // } // // @Override // public void clearLayers() { // super.clearLayers(); // mNewId = 0; // } // // public void setDirty(boolean dirty) { // mDirty = dirty; // } // // public boolean isDirty() { // return mDirty; // } // } // // Path: src/main/java/com/nextgis/maplib/util/DatabaseContext.java // public class DatabaseContext // extends ContextWrapper // { // protected File mDatabasePath; // // // public DatabaseContext( // Context base, // File databasePath) // { // super(base); // mDatabasePath = databasePath; // } // // // @Override // public File getDatabasePath(String name) // { // String dbfile = mDatabasePath + File.separator + name; // if (!dbfile.endsWith(".db")) { // dbfile += ".db"; // } // // if (!mDatabasePath.exists()) { // mDatabasePath.mkdirs(); // } // // return new File(dbfile); // } // // // @Override // public SQLiteDatabase openOrCreateDatabase( // String name, // int mode, // SQLiteDatabase.CursorFactory factory, // DatabaseErrorHandler errorHandler) // { // return SQLiteDatabase.openOrCreateDatabase( // getDatabasePath(name).getAbsolutePath(), factory, errorHandler); // } // // // @Override // public SQLiteDatabase openOrCreateDatabase( // String name, // int mode, // SQLiteDatabase.CursorFactory factory) // { // SQLiteDatabase result = null; // try { // result = SQLiteDatabase.openOrCreateDatabase(getDatabasePath(name), factory); // } catch (SQLiteException e) { // e.printStackTrace(); // } // return result; // } // // public static SQLiteDatabase getDbForLayer(final VectorLayer layer){ // MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance(); // SQLiteDatabase db = map.getDatabase(false); // // speedup writing // db.rawQuery("PRAGMA synchronous=OFF", null); // //db.rawQuery("PRAGMA locking_mode=EXCLUSIVE", null); // db.rawQuery("PRAGMA journal_mode=OFF", null); // db.rawQuery("PRAGMA count_changes=OFF", null); // db.rawQuery("PRAGMA cache_size=15000", null); // // return db; // } // } // Path: src/main/java/com/nextgis/maplib/datasource/DatabaseHelper.java import com.nextgis.maplib.map.MapBase; import com.nextgis.maplib.util.DatabaseContext; import java.io.File; import android.annotation.TargetApi; import android.content.Context; import android.database.DatabaseErrorHandler; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.os.Build; SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) { super( new DatabaseContext(context, dbFullName.getParentFile()), dbFullName.getName(), factory, version, errorHandler); } /** * is called whenever the app is freshly installed * @param sqLiteDatabase Database */ @Override public void onCreate(SQLiteDatabase sqLiteDatabase) { } /** * is called whenever the app is upgraded and launched and the database version is not the same * @param sqLiteDatabase Database * @param oldVersion The previous database version * @param newVersion The current database version */ @Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
MapBase map = MapBase.getInstance();
nextgis/android_maplib
src/main/java/com/nextgis/maplib/datasource/GeoGeometryCollection.java
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // }
import org.json.JSONObject; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.LinkedList; import java.util.List; import static com.nextgis.maplib.util.GeoConstants.GEOJSON_GEOMETRIES; import static com.nextgis.maplib.util.GeoConstants.GEOJSON_TYPE; import static com.nextgis.maplib.util.GeoConstants.GEOJSON_TYPE_GeometryCollection; import static com.nextgis.maplib.util.GeoConstants.GTGeometryCollection; import android.annotation.TargetApi; import android.os.Build; import android.util.JsonReader; import com.nextgis.maplib.util.GeoConstants; import org.json.JSONArray; import org.json.JSONException;
if (geometry == null) { throw new IllegalArgumentException("GeoGeometryCollection: geometry == null."); } if(index >= mGeometries.size()) mGeometries.add(geometry); else mGeometries.set(index, geometry); } public GeoGeometry remove(int index) { return mGeometries.remove(index); } public GeoGeometry get(int index) { return mGeometries.get(index); } public int size() { return mGeometries.size(); } @Override public int getType() {
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // } // Path: src/main/java/com/nextgis/maplib/datasource/GeoGeometryCollection.java import org.json.JSONObject; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.LinkedList; import java.util.List; import static com.nextgis.maplib.util.GeoConstants.GEOJSON_GEOMETRIES; import static com.nextgis.maplib.util.GeoConstants.GEOJSON_TYPE; import static com.nextgis.maplib.util.GeoConstants.GEOJSON_TYPE_GeometryCollection; import static com.nextgis.maplib.util.GeoConstants.GTGeometryCollection; import android.annotation.TargetApi; import android.os.Build; import android.util.JsonReader; import com.nextgis.maplib.util.GeoConstants; import org.json.JSONArray; import org.json.JSONException; if (geometry == null) { throw new IllegalArgumentException("GeoGeometryCollection: geometry == null."); } if(index >= mGeometries.size()) mGeometries.add(geometry); else mGeometries.set(index, geometry); } public GeoGeometry remove(int index) { return mGeometries.remove(index); } public GeoGeometry get(int index) { return mGeometries.get(index); } public int size() { return mGeometries.size(); } @Override public int getType() {
return GeoConstants.GTGeometryCollection;
nextgis/android_maplib
src/main/java/com/nextgis/maplib/display/Style.java
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/datasource/GeoGeometry.java // public abstract class GeoGeometry // implements Serializable // { // protected static final long serialVersionUID = -1241179697270831761L; // protected int mCRS; // // // public boolean project(int toCrs) // { // return (mCRS == CRS_WGS84 && toCrs == CRS_WEB_MERCATOR || // mCRS == CRS_WEB_MERCATOR && toCrs == CRS_WGS84) && rawProject(toCrs); // } // // // protected boolean rawProject(int toCrs) // { // mCRS = toCrs; // return true; // } // // // public abstract GeoEnvelope getEnvelope(); // // // public void setCRS(int crs) // { // mCRS = crs; // } // // // public int getCRS() // { // return mCRS; // } // // // public JSONObject toJSON() // throws JSONException // { // JSONObject jsonOutObject = new JSONObject(); // jsonOutObject.put(GEOJSON_TYPE, typeToJSON()); // jsonOutObject.put(GEOJSON_COORDINATES, coordinatesToJSON()); // // return jsonOutObject; // } // // // public String typeToJSON() // { // switch (getType()) { // case GTPoint: // return GEOJSON_TYPE_Point; // case GTLineString: // return GEOJSON_TYPE_LineString; // case GTPolygon: // return GEOJSON_TYPE_Polygon; // case GTMultiPoint: // return GEOJSON_TYPE_MultiPoint; // case GTMultiLineString: // return GEOJSON_TYPE_MultiLineString; // case GTMultiPolygon: // return GEOJSON_TYPE_MultiPolygon; // case GTGeometryCollection: // return GEOJSON_TYPE_GeometryCollection; // case GTNone: // default: // return ""; // } // } // // // public abstract JSONArray coordinatesToJSON() // throws JSONException, ClassCastException; // // // public abstract int getType(); // // // public abstract void setCoordinatesFromJSON(JSONArray coordinates) // throws JSONException; // // public abstract void setCoordinatesFromJSONStream(JsonReader reader, int crs) // throws IOException; // // public abstract void setCoordinatesFromWKT(String wkt, int crs); // // // public byte[] toBlobOld() // throws IOException // { // ByteArrayOutputStream out = new ByteArrayOutputStream(); // ObjectOutputStream os = new ObjectOutputStream(out); // os.writeObject(this); // return out.toByteArray(); // } // // // public byte[] toBlob() // throws IOException // { // ByteArrayOutputStream out = new ByteArrayOutputStream(); // DataOutputStream dataOutputStream = new DataOutputStream(out); // write(dataOutputStream); // return out.toByteArray(); // } // // // public abstract String toWKT(boolean full); // // // public boolean equals(Object o) // { // if (super.equals(o)) { // return true; // } // GeoGeometry other = (GeoGeometry) o; // return null != other && getType() == other.getType() && mCRS == other.getCRS(); // } // // // public boolean intersects(GeoEnvelope envelope) // { // return getEnvelope().intersects(envelope); // } // // // /** // * Make deep copy of geometry // * // * @return The geometry copy // */ // public abstract GeoGeometry copy(); // // /** // * remove all points from geometry // */ // public abstract void clear(); // // public abstract GeoGeometry simplify(double tolerance); // // public abstract GeoGeometry clip(GeoEnvelope envelope); // // public void write(DataOutputStream stream) throws IOException{ // stream.writeInt(getType()); // stream.writeInt(mCRS); // } // // public void read(DataInputStream stream) throws IOException{ // mCRS = stream.readInt(); // } // // public abstract boolean isValid(); // // public abstract double distance(GeoGeometry geometry); // }
import static com.nextgis.maplib.util.Constants.JSON_COLOR_KEY; import static com.nextgis.maplib.util.Constants.JSON_OUTALPHA_KEY; import static com.nextgis.maplib.util.Constants.JSON_OUTCOLOR_KEY; import static com.nextgis.maplib.util.Constants.JSON_WIDTH_KEY; import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.datasource.GeoGeometry; import org.json.JSONException; import org.json.JSONObject; import static com.nextgis.maplib.util.Constants.JSON_ALPHA_KEY;
public int getColor() { return mColor; } public void setColor(int color) { mColor = color; } public int getOutColor() { return mOutColor; } public void setOutColor(int outColor) { mOutColor = outColor; } public float getWidth() { return mWidth; } public void setWidth(float width) { mWidth = width; } public Style(final int color, int outColor) { this(); mColor = color; mOutColor = outColor; }
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/datasource/GeoGeometry.java // public abstract class GeoGeometry // implements Serializable // { // protected static final long serialVersionUID = -1241179697270831761L; // protected int mCRS; // // // public boolean project(int toCrs) // { // return (mCRS == CRS_WGS84 && toCrs == CRS_WEB_MERCATOR || // mCRS == CRS_WEB_MERCATOR && toCrs == CRS_WGS84) && rawProject(toCrs); // } // // // protected boolean rawProject(int toCrs) // { // mCRS = toCrs; // return true; // } // // // public abstract GeoEnvelope getEnvelope(); // // // public void setCRS(int crs) // { // mCRS = crs; // } // // // public int getCRS() // { // return mCRS; // } // // // public JSONObject toJSON() // throws JSONException // { // JSONObject jsonOutObject = new JSONObject(); // jsonOutObject.put(GEOJSON_TYPE, typeToJSON()); // jsonOutObject.put(GEOJSON_COORDINATES, coordinatesToJSON()); // // return jsonOutObject; // } // // // public String typeToJSON() // { // switch (getType()) { // case GTPoint: // return GEOJSON_TYPE_Point; // case GTLineString: // return GEOJSON_TYPE_LineString; // case GTPolygon: // return GEOJSON_TYPE_Polygon; // case GTMultiPoint: // return GEOJSON_TYPE_MultiPoint; // case GTMultiLineString: // return GEOJSON_TYPE_MultiLineString; // case GTMultiPolygon: // return GEOJSON_TYPE_MultiPolygon; // case GTGeometryCollection: // return GEOJSON_TYPE_GeometryCollection; // case GTNone: // default: // return ""; // } // } // // // public abstract JSONArray coordinatesToJSON() // throws JSONException, ClassCastException; // // // public abstract int getType(); // // // public abstract void setCoordinatesFromJSON(JSONArray coordinates) // throws JSONException; // // public abstract void setCoordinatesFromJSONStream(JsonReader reader, int crs) // throws IOException; // // public abstract void setCoordinatesFromWKT(String wkt, int crs); // // // public byte[] toBlobOld() // throws IOException // { // ByteArrayOutputStream out = new ByteArrayOutputStream(); // ObjectOutputStream os = new ObjectOutputStream(out); // os.writeObject(this); // return out.toByteArray(); // } // // // public byte[] toBlob() // throws IOException // { // ByteArrayOutputStream out = new ByteArrayOutputStream(); // DataOutputStream dataOutputStream = new DataOutputStream(out); // write(dataOutputStream); // return out.toByteArray(); // } // // // public abstract String toWKT(boolean full); // // // public boolean equals(Object o) // { // if (super.equals(o)) { // return true; // } // GeoGeometry other = (GeoGeometry) o; // return null != other && getType() == other.getType() && mCRS == other.getCRS(); // } // // // public boolean intersects(GeoEnvelope envelope) // { // return getEnvelope().intersects(envelope); // } // // // /** // * Make deep copy of geometry // * // * @return The geometry copy // */ // public abstract GeoGeometry copy(); // // /** // * remove all points from geometry // */ // public abstract void clear(); // // public abstract GeoGeometry simplify(double tolerance); // // public abstract GeoGeometry clip(GeoEnvelope envelope); // // public void write(DataOutputStream stream) throws IOException{ // stream.writeInt(getType()); // stream.writeInt(mCRS); // } // // public void read(DataInputStream stream) throws IOException{ // mCRS = stream.readInt(); // } // // public abstract boolean isValid(); // // public abstract double distance(GeoGeometry geometry); // } // Path: src/main/java/com/nextgis/maplib/display/Style.java import static com.nextgis.maplib.util.Constants.JSON_COLOR_KEY; import static com.nextgis.maplib.util.Constants.JSON_OUTALPHA_KEY; import static com.nextgis.maplib.util.Constants.JSON_OUTCOLOR_KEY; import static com.nextgis.maplib.util.Constants.JSON_WIDTH_KEY; import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.datasource.GeoGeometry; import org.json.JSONException; import org.json.JSONObject; import static com.nextgis.maplib.util.Constants.JSON_ALPHA_KEY; public int getColor() { return mColor; } public void setColor(int color) { mColor = color; } public int getOutColor() { return mOutColor; } public void setOutColor(int outColor) { mOutColor = outColor; } public float getWidth() { return mWidth; } public void setWidth(float width) { mWidth = width; } public Style(final int color, int outColor) { this(); mColor = color; mOutColor = outColor; }
public abstract void onDraw(GeoGeometry geoGeometry, GISDisplay display);
nextgis/android_maplib
src/main/java/com/nextgis/maplib/datasource/GeoMultiPoint.java
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // }
import java.io.IOException; import android.annotation.TargetApi; import android.os.Build; import android.util.JsonReader; import com.nextgis.maplib.util.GeoConstants; import org.json.JSONArray; import org.json.JSONException;
/* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.datasource; public class GeoMultiPoint extends GeoGeometryCollection { protected static final long serialVersionUID = -1241179697270831765L; public GeoMultiPoint(GeoMultiPoint geoMultiPoint) { super(geoMultiPoint); } public GeoMultiPoint() { super(); } @Override public void add(GeoGeometry geometry) throws ClassCastException { if (!(geometry instanceof GeoPoint)) { throw new ClassCastException("GeoMultiPoint: geometry is not GeoPoint type."); } super.add(geometry); } @Override public GeoPoint get(int index) { return (GeoPoint) mGeometries.get(index); } @Override public int getType() {
// Path: src/main/java/com/nextgis/maplib/util/GeoConstants.java // public interface GeoConstants // { // // /** // * Mercator projection constants // */ // double MERCATOR_MAX = 20037508.34; // double WGS_LONG_MAX = 180; // double WGS_LAT_MAX = 90; // // /** // * TMS type // */ // int TMSTYPE_NORMAL = 1; // int TMSTYPE_OSM = 2; // // int DEFAULT_MAX_ZOOM = 25; // int DEFAULT_CACHE_MAX_ZOOM = 18; // int DEFAULT_MIN_ZOOM = 0; // // /** // * geometry type // */ // int GTPoint = 1; // int GTLineString = 2; // int GTPolygon = 3; // int GTMultiPoint = 4; // int GTMultiLineString = 5; // int GTMultiPolygon = 6; // int GTGeometryCollection = 7; // int GTNone = 100; // int GTLinearRing = 200; // // int GTPointCheck = 1 << GTPoint; // int GTLineStringCheck = 1 << GTLineString; // int GTPolygonCheck = 1 << GTPolygon; // int GTMultiPointCheck = 1 << GTMultiPoint; // int GTMultiLineStringCheck = 1 << GTMultiLineString; // int GTMultiPolygonCheck = 1 << GTMultiPolygon; // int GTGeometryCollectionCheck = 1 << GTGeometryCollection; // int GTNoneCheck = 1 << 10; // int GTAnyCheck = // GTMultiPointCheck | GTPointCheck | GTLineStringCheck | GTMultiLineStringCheck | // GTPolygonCheck | GTMultiPolygonCheck | GTGeometryCollectionCheck; // // /** // * geojson see http://geojson.org/geojson-spec.html // */ // String GEOJSON_CRS_EPSG_4326 = "EPSG:4326"; // String GEOJSON_CRS_WGS84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; // String GEOJSON_CRS_WEB_MERCATOR = "EPSG:3857"; // String GEOJSON_CRS_EPSG_3857 = "urn:ogc:def:crs:EPSG::3857"; // String GEOJSON_TYPE = "type"; // String GEOJSON_ID = "id"; // String GEOJSON_FEATURE_ID = "FEATURE_ID"; // String GEOJSON_CRS = "crs"; // String GEOJSON_NAME = "name"; // String GEOJSON_PROPERTIES = "properties"; // String GEOJSON_ATTACHES = "attaches"; // String GEOJSON_BBOX = "bbox"; // String GEOJSON_TYPE_FEATURES = "features"; // String GEOJSON_GEOMETRY = "geometry"; // String GEOJSON_GEOMETRIES = "geometries"; // String GEOJSON_COORDINATES = "coordinates"; // String GEOJSON_TYPE_Point = "Point"; // String GEOJSON_TYPE_MultiPoint = "MultiPoint"; // String GEOJSON_TYPE_LineString = "LineString"; // String GEOJSON_TYPE_MultiLineString = "MultiLineString"; // String GEOJSON_TYPE_Polygon = "Polygon"; // String GEOJSON_TYPE_MultiPolygon = "MultiPolygon"; // String GEOJSON_TYPE_GeometryCollection = "GeometryCollection"; // String GEOJSON_TYPE_Feature = "Feature"; // String GEOJSON_TYPE_FeatureCollection = "FeatureCollection"; // // /** // * field type // */ // int FTInteger = 0; // int FTIntegerList = 1; // int FTReal = 2; // int FTRealList = 3; // int FTString = 4; // int FTStringList = 5; // int FTBinary = 8; // int FTDateTime = 10; // int FTDate = 11; // int FTTime = 12; // // /** // * CRS // */ // int CRS_WGS84 = 4326; // int CRS_WEB_MERCATOR = 3857; // // } // Path: src/main/java/com/nextgis/maplib/datasource/GeoMultiPoint.java import java.io.IOException; import android.annotation.TargetApi; import android.os.Build; import android.util.JsonReader; import com.nextgis.maplib.util.GeoConstants; import org.json.JSONArray; import org.json.JSONException; /* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.datasource; public class GeoMultiPoint extends GeoGeometryCollection { protected static final long serialVersionUID = -1241179697270831765L; public GeoMultiPoint(GeoMultiPoint geoMultiPoint) { super(geoMultiPoint); } public GeoMultiPoint() { super(); } @Override public void add(GeoGeometry geometry) throws ClassCastException { if (!(geometry instanceof GeoPoint)) { throw new ClassCastException("GeoMultiPoint: geometry is not GeoPoint type."); } super.add(geometry); } @Override public GeoPoint get(int index) { return (GeoPoint) mGeometries.get(index); } @Override public int getType() {
return GeoConstants.GTMultiPoint;
nextgis/android_maplib
src/main/java/com/nextgis/maplib/display/Renderer.java
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/api/ILayer.java // public interface ILayer // { // /** // * @return Application context // */ // Context getContext(); // // /** // * @return User readable layer name // */ // String getName(); // // /** // * Set layer name // * @param newName New name // */ // void setName(String newName); // // /** // * @return Layer identofoctor - set by map on current session // */ // int getId(); // // /** // * Get Layer type (@see com.nextgis.maplib.util.Constants) // * @return Layer type // */ // int getType(); // // /** // * Delete layer // * @return true on success or false // */ // boolean delete(); // // /** // * Get layer path in storage // * @return Layer path // */ // File getPath(); // // /** // * Save layer changes // * @return true on success or false // */ // boolean save(); // // /** // * Load layer // * @return true on success or false // */ // boolean load(); // // /** // * Get layer extents // * @return Layer extents in map coordinates // */ // GeoEnvelope getExtents(); // // /** // * set layer parent // * @param layer Layer parent object // */ // void setParent(ILayer layer); // // /** // * @return Layer parent object // */ // ILayer getParent(); // // /** // * Set layer internal identifictor - set by map on current session // * @param id New layer identificator // */ // void setId(int id); // // /** // * @return Is layer valid (all data are present, .etc.) // */ // boolean isValid(); // // /** // * Triggered on layer contents or properties changes // */ // void notifyUpdateAll(); // // /** // * Triggered on layer contents changed // * @param rowId New record id // * @param oldRowId Old record id // * @param attributesOnly // */ // void notifyUpdate(long rowId, long oldRowId, boolean attributesOnly); // // /** // * Triggered on layer added new record // * @param rowId New record id // */ // void notifyInsert(long rowId); // // /** // * Triggered on layer delete all records // */ // void notifyDeleteAll(); // // /** // * Triggered on layer delete record // * @param rowId Deleted record id // */ // void notifyDelete(long rowId); // // /** // * Executed then database version is changes. Triggered on application upgrade // * @param sqLiteDatabase The database // * @param oldVersion Old database version // * @param newVersion New database version // */ // void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion); // } // // Path: src/main/java/com/nextgis/maplib/api/IRenderer.java // public interface IRenderer // { // /** // * Start draw process // * @param display The display object where to draw // */ // void runDraw(final GISDisplay display); // // /** // * Cancel draw process // */ // void cancelDraw(); // }
import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.api.ILayer; import com.nextgis.maplib.api.IRenderer; import java.lang.ref.WeakReference;
/* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.display; public abstract class Renderer implements IJSONStore,
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/api/ILayer.java // public interface ILayer // { // /** // * @return Application context // */ // Context getContext(); // // /** // * @return User readable layer name // */ // String getName(); // // /** // * Set layer name // * @param newName New name // */ // void setName(String newName); // // /** // * @return Layer identofoctor - set by map on current session // */ // int getId(); // // /** // * Get Layer type (@see com.nextgis.maplib.util.Constants) // * @return Layer type // */ // int getType(); // // /** // * Delete layer // * @return true on success or false // */ // boolean delete(); // // /** // * Get layer path in storage // * @return Layer path // */ // File getPath(); // // /** // * Save layer changes // * @return true on success or false // */ // boolean save(); // // /** // * Load layer // * @return true on success or false // */ // boolean load(); // // /** // * Get layer extents // * @return Layer extents in map coordinates // */ // GeoEnvelope getExtents(); // // /** // * set layer parent // * @param layer Layer parent object // */ // void setParent(ILayer layer); // // /** // * @return Layer parent object // */ // ILayer getParent(); // // /** // * Set layer internal identifictor - set by map on current session // * @param id New layer identificator // */ // void setId(int id); // // /** // * @return Is layer valid (all data are present, .etc.) // */ // boolean isValid(); // // /** // * Triggered on layer contents or properties changes // */ // void notifyUpdateAll(); // // /** // * Triggered on layer contents changed // * @param rowId New record id // * @param oldRowId Old record id // * @param attributesOnly // */ // void notifyUpdate(long rowId, long oldRowId, boolean attributesOnly); // // /** // * Triggered on layer added new record // * @param rowId New record id // */ // void notifyInsert(long rowId); // // /** // * Triggered on layer delete all records // */ // void notifyDeleteAll(); // // /** // * Triggered on layer delete record // * @param rowId Deleted record id // */ // void notifyDelete(long rowId); // // /** // * Executed then database version is changes. Triggered on application upgrade // * @param sqLiteDatabase The database // * @param oldVersion Old database version // * @param newVersion New database version // */ // void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion); // } // // Path: src/main/java/com/nextgis/maplib/api/IRenderer.java // public interface IRenderer // { // /** // * Start draw process // * @param display The display object where to draw // */ // void runDraw(final GISDisplay display); // // /** // * Cancel draw process // */ // void cancelDraw(); // } // Path: src/main/java/com/nextgis/maplib/display/Renderer.java import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.api.ILayer; import com.nextgis.maplib.api.IRenderer; import java.lang.ref.WeakReference; /* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.display; public abstract class Renderer implements IJSONStore,
IRenderer
nextgis/android_maplib
src/main/java/com/nextgis/maplib/display/Renderer.java
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/api/ILayer.java // public interface ILayer // { // /** // * @return Application context // */ // Context getContext(); // // /** // * @return User readable layer name // */ // String getName(); // // /** // * Set layer name // * @param newName New name // */ // void setName(String newName); // // /** // * @return Layer identofoctor - set by map on current session // */ // int getId(); // // /** // * Get Layer type (@see com.nextgis.maplib.util.Constants) // * @return Layer type // */ // int getType(); // // /** // * Delete layer // * @return true on success or false // */ // boolean delete(); // // /** // * Get layer path in storage // * @return Layer path // */ // File getPath(); // // /** // * Save layer changes // * @return true on success or false // */ // boolean save(); // // /** // * Load layer // * @return true on success or false // */ // boolean load(); // // /** // * Get layer extents // * @return Layer extents in map coordinates // */ // GeoEnvelope getExtents(); // // /** // * set layer parent // * @param layer Layer parent object // */ // void setParent(ILayer layer); // // /** // * @return Layer parent object // */ // ILayer getParent(); // // /** // * Set layer internal identifictor - set by map on current session // * @param id New layer identificator // */ // void setId(int id); // // /** // * @return Is layer valid (all data are present, .etc.) // */ // boolean isValid(); // // /** // * Triggered on layer contents or properties changes // */ // void notifyUpdateAll(); // // /** // * Triggered on layer contents changed // * @param rowId New record id // * @param oldRowId Old record id // * @param attributesOnly // */ // void notifyUpdate(long rowId, long oldRowId, boolean attributesOnly); // // /** // * Triggered on layer added new record // * @param rowId New record id // */ // void notifyInsert(long rowId); // // /** // * Triggered on layer delete all records // */ // void notifyDeleteAll(); // // /** // * Triggered on layer delete record // * @param rowId Deleted record id // */ // void notifyDelete(long rowId); // // /** // * Executed then database version is changes. Triggered on application upgrade // * @param sqLiteDatabase The database // * @param oldVersion Old database version // * @param newVersion New database version // */ // void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion); // } // // Path: src/main/java/com/nextgis/maplib/api/IRenderer.java // public interface IRenderer // { // /** // * Start draw process // * @param display The display object where to draw // */ // void runDraw(final GISDisplay display); // // /** // * Cancel draw process // */ // void cancelDraw(); // }
import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.api.ILayer; import com.nextgis.maplib.api.IRenderer; import java.lang.ref.WeakReference;
/* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.display; public abstract class Renderer implements IJSONStore, IRenderer { protected static int mCPUTotalCount; // for avoid circular references and memory leak
// Path: src/main/java/com/nextgis/maplib/api/IJSONStore.java // public interface IJSONStore // { // /** // * Store object in json // * @return json object with stored data // * @throws JSONException // */ // JSONObject toJSON() // throws JSONException; // // /** // * Restore object from json // * @param jsonObject where the stored data are // * @throws JSONException // */ // void fromJSON(JSONObject jsonObject) // throws JSONException; // } // // Path: src/main/java/com/nextgis/maplib/api/ILayer.java // public interface ILayer // { // /** // * @return Application context // */ // Context getContext(); // // /** // * @return User readable layer name // */ // String getName(); // // /** // * Set layer name // * @param newName New name // */ // void setName(String newName); // // /** // * @return Layer identofoctor - set by map on current session // */ // int getId(); // // /** // * Get Layer type (@see com.nextgis.maplib.util.Constants) // * @return Layer type // */ // int getType(); // // /** // * Delete layer // * @return true on success or false // */ // boolean delete(); // // /** // * Get layer path in storage // * @return Layer path // */ // File getPath(); // // /** // * Save layer changes // * @return true on success or false // */ // boolean save(); // // /** // * Load layer // * @return true on success or false // */ // boolean load(); // // /** // * Get layer extents // * @return Layer extents in map coordinates // */ // GeoEnvelope getExtents(); // // /** // * set layer parent // * @param layer Layer parent object // */ // void setParent(ILayer layer); // // /** // * @return Layer parent object // */ // ILayer getParent(); // // /** // * Set layer internal identifictor - set by map on current session // * @param id New layer identificator // */ // void setId(int id); // // /** // * @return Is layer valid (all data are present, .etc.) // */ // boolean isValid(); // // /** // * Triggered on layer contents or properties changes // */ // void notifyUpdateAll(); // // /** // * Triggered on layer contents changed // * @param rowId New record id // * @param oldRowId Old record id // * @param attributesOnly // */ // void notifyUpdate(long rowId, long oldRowId, boolean attributesOnly); // // /** // * Triggered on layer added new record // * @param rowId New record id // */ // void notifyInsert(long rowId); // // /** // * Triggered on layer delete all records // */ // void notifyDeleteAll(); // // /** // * Triggered on layer delete record // * @param rowId Deleted record id // */ // void notifyDelete(long rowId); // // /** // * Executed then database version is changes. Triggered on application upgrade // * @param sqLiteDatabase The database // * @param oldVersion Old database version // * @param newVersion New database version // */ // void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion); // } // // Path: src/main/java/com/nextgis/maplib/api/IRenderer.java // public interface IRenderer // { // /** // * Start draw process // * @param display The display object where to draw // */ // void runDraw(final GISDisplay display); // // /** // * Cancel draw process // */ // void cancelDraw(); // } // Path: src/main/java/com/nextgis/maplib/display/Renderer.java import com.nextgis.maplib.api.IJSONStore; import com.nextgis.maplib.api.ILayer; import com.nextgis.maplib.api.IRenderer; import java.lang.ref.WeakReference; /* * Project: NextGIS Mobile * Purpose: Mobile GIS for Android. * Author: Dmitry Baryshnikov (aka Bishop), bishop.dev@gmail.com * Author: NikitaFeodonit, nfeodonit@yandex.com * Author: Stanislav Petriakov, becomeglory@gmail.com * ***************************************************************************** * Copyright (c) 2012-2015. NextGIS, info@nextgis.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nextgis.maplib.display; public abstract class Renderer implements IJSONStore, IRenderer { protected static int mCPUTotalCount; // for avoid circular references and memory leak
protected final WeakReference<ILayer> mLayerRef;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/ConfigFileJoL.java
// Path: Journey of Legends/aginsun/journey/universal/blocks/InitBlocks.java // public class InitBlocks // { // public static Block BlockSell; // public static Block BlockKingdom; // public static Block BlockReader; // // public static int BlockSellID; // public static int BlockKingdomID; // // public static void Init() // { // BlockSell = new BlockSell(BlockSellID).setResistance(100000.0F).setHardness(120000.0F).setBlockUnbreakable(); // GameRegistry.registerBlock(BlockSell, "BlockSell"); // } // } // // Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // }
import net.minecraftforge.common.Configuration; import aginsun.journey.universal.blocks.InitBlocks; import aginsun.journey.universal.items.InitItems; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
package aginsun.journey.universal; public class ConfigFileJoL { public static boolean GuildSpawning; public static int xLocation; public static int yLocation; public static int zLocation; public static void config(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load();
// Path: Journey of Legends/aginsun/journey/universal/blocks/InitBlocks.java // public class InitBlocks // { // public static Block BlockSell; // public static Block BlockKingdom; // public static Block BlockReader; // // public static int BlockSellID; // public static int BlockKingdomID; // // public static void Init() // { // BlockSell = new BlockSell(BlockSellID).setResistance(100000.0F).setHardness(120000.0F).setBlockUnbreakable(); // GameRegistry.registerBlock(BlockSell, "BlockSell"); // } // } // // Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // } // Path: Journey of Legends/aginsun/journey/universal/ConfigFileJoL.java import net.minecraftforge.common.Configuration; import aginsun.journey.universal.blocks.InitBlocks; import aginsun.journey.universal.items.InitItems; import cpw.mods.fml.common.event.FMLPreInitializationEvent; package aginsun.journey.universal; public class ConfigFileJoL { public static boolean GuildSpawning; public static int xLocation; public static int yLocation; public static int zLocation; public static void config(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load();
InitBlocks.BlockSellID = config.getBlock("SellBlock", 1750).getInt();
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/ConfigFileJoL.java
// Path: Journey of Legends/aginsun/journey/universal/blocks/InitBlocks.java // public class InitBlocks // { // public static Block BlockSell; // public static Block BlockKingdom; // public static Block BlockReader; // // public static int BlockSellID; // public static int BlockKingdomID; // // public static void Init() // { // BlockSell = new BlockSell(BlockSellID).setResistance(100000.0F).setHardness(120000.0F).setBlockUnbreakable(); // GameRegistry.registerBlock(BlockSell, "BlockSell"); // } // } // // Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // }
import net.minecraftforge.common.Configuration; import aginsun.journey.universal.blocks.InitBlocks; import aginsun.journey.universal.items.InitItems; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
package aginsun.journey.universal; public class ConfigFileJoL { public static boolean GuildSpawning; public static int xLocation; public static int yLocation; public static int zLocation; public static void config(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); InitBlocks.BlockSellID = config.getBlock("SellBlock", 1750).getInt(); InitBlocks.BlockKingdomID = config.getBlock("KingdomBlock", 1751).getInt();
// Path: Journey of Legends/aginsun/journey/universal/blocks/InitBlocks.java // public class InitBlocks // { // public static Block BlockSell; // public static Block BlockKingdom; // public static Block BlockReader; // // public static int BlockSellID; // public static int BlockKingdomID; // // public static void Init() // { // BlockSell = new BlockSell(BlockSellID).setResistance(100000.0F).setHardness(120000.0F).setBlockUnbreakable(); // GameRegistry.registerBlock(BlockSell, "BlockSell"); // } // } // // Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // } // Path: Journey of Legends/aginsun/journey/universal/ConfigFileJoL.java import net.minecraftforge.common.Configuration; import aginsun.journey.universal.blocks.InitBlocks; import aginsun.journey.universal.items.InitItems; import cpw.mods.fml.common.event.FMLPreInitializationEvent; package aginsun.journey.universal; public class ConfigFileJoL { public static boolean GuildSpawning; public static int xLocation; public static int yLocation; public static int zLocation; public static void config(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); InitBlocks.BlockSellID = config.getBlock("SellBlock", 1750).getInt(); InitBlocks.BlockKingdomID = config.getBlock("KingdomBlock", 1751).getInt();
InitItems.ItemCoinsID = config.getItem("Coins", 22125).getInt();
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketGold.java
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.GoldKeeper; import cpw.mods.fml.common.network.Player;
package aginsun.journey.universal.packets; public class PacketGold extends PacketJoL { private String username; private int GoldValue; public PacketGold() { super(PacketType.GOLD, false); } public PacketGold(String username, int GoldValue) { super(PacketType.GOLD, false); this.username = username; this.GoldValue = GoldValue; } @Override public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.GoldValue = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(GoldValue); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketGold.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.GoldKeeper; import cpw.mods.fml.common.network.Player; package aginsun.journey.universal.packets; public class PacketGold extends PacketJoL { private String username; private int GoldValue; public PacketGold() { super(PacketType.GOLD, false); } public PacketGold(String username, int GoldValue) { super(PacketType.GOLD, false); this.username = username; this.GoldValue = GoldValue; } @Override public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.GoldValue = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(GoldValue); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
GoldKeeper.setGold(thePlayer, GoldValue);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/handlers/GoldValueHandler.java
// Path: Journey of Legends/aginsun/journey/JourneyofLegends.java // @Mod(modid = Utils.modID, version = Utils.Version, name = Utils.Name) // @NetworkMod(channels = { Utils.modID },clientSideRequired = true, serverSideRequired = true, packetHandler = PacketHandler.class) // public class JourneyofLegends // { // @Instance (Utils.modID) // public static JourneyofLegends instance = new JourneyofLegends(); // // @SidedProxy(clientSide="aginsun.journey.client.core.ClientProxy",serverSide="aginsun.journey.core.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void PreInit(FMLPreInitializationEvent event) // { // ConfigFileJoL.config(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) // { // InitEntities.Init(); // // InitBlocks.Init(); // // InitItems.Init(); // // NetworkRegistry.instance().registerGuiHandler(instance, proxy); // // TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); // // MinecraftForge.EVENT_BUS.register(new EntityLivingHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingAttackEventHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingDeathEventHandler()); // // proxy.RegisterRenderers(); // // WorldgenChests.Init(); // } // // @EventHandler // public void PostInit(FMLPostInitializationEvent event) // { // proxy.registerPostInit(); // // GoldValueHandler.setGoldValues(); // // QuestRegistry.InitQuests(); // } // // @EventHandler // public void serverStarting(FMLServerStartingEvent event) // { // CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager(); // commandManager.registerCommand(new CommandJoLHandler()); // } // // @EventHandler // public void serverStarted(FMLServerStartedEvent event) // { // GameRegistry.registerPlayerTracker(new SaveHandler()); // GameRegistry.registerPickupHandler(new PickupHandler()); // } // }
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import aginsun.journey.JourneyofLegends;
package aginsun.journey.universal.handlers; /**sets all the gold values for the vanilla items * and also any mod items that I want to be added. * * note: Evydder did the old system! * @author Aginsun, Evydder * */ public class GoldValueHandler { public static HashMap<String, Integer> goldValues = new HashMap<String, Integer>(); public static void setGoldValues() { goldValues.clear();
// Path: Journey of Legends/aginsun/journey/JourneyofLegends.java // @Mod(modid = Utils.modID, version = Utils.Version, name = Utils.Name) // @NetworkMod(channels = { Utils.modID },clientSideRequired = true, serverSideRequired = true, packetHandler = PacketHandler.class) // public class JourneyofLegends // { // @Instance (Utils.modID) // public static JourneyofLegends instance = new JourneyofLegends(); // // @SidedProxy(clientSide="aginsun.journey.client.core.ClientProxy",serverSide="aginsun.journey.core.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void PreInit(FMLPreInitializationEvent event) // { // ConfigFileJoL.config(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) // { // InitEntities.Init(); // // InitBlocks.Init(); // // InitItems.Init(); // // NetworkRegistry.instance().registerGuiHandler(instance, proxy); // // TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); // // MinecraftForge.EVENT_BUS.register(new EntityLivingHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingAttackEventHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingDeathEventHandler()); // // proxy.RegisterRenderers(); // // WorldgenChests.Init(); // } // // @EventHandler // public void PostInit(FMLPostInitializationEvent event) // { // proxy.registerPostInit(); // // GoldValueHandler.setGoldValues(); // // QuestRegistry.InitQuests(); // } // // @EventHandler // public void serverStarting(FMLServerStartingEvent event) // { // CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager(); // commandManager.registerCommand(new CommandJoLHandler()); // } // // @EventHandler // public void serverStarted(FMLServerStartedEvent event) // { // GameRegistry.registerPlayerTracker(new SaveHandler()); // GameRegistry.registerPickupHandler(new PickupHandler()); // } // } // Path: Journey of Legends/aginsun/journey/universal/handlers/GoldValueHandler.java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import aginsun.journey.JourneyofLegends; package aginsun.journey.universal.handlers; /**sets all the gold values for the vanilla items * and also any mod items that I want to be added. * * note: Evydder did the old system! * @author Aginsun, Evydder * */ public class GoldValueHandler { public static HashMap<String, Integer> goldValues = new HashMap<String, Integer>(); public static void setGoldValues() { goldValues.clear();
InputStream input = JourneyofLegends.class.getResourceAsStream("/assets/journeyoflegends/textures/utils/GoldValues.txt");
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketQuestData.java
// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java // public class QuestHandler // { // private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); // private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); // private static QuestHandler instance = new QuestHandler(); // // public QuestHandler(){} // // public static QuestHandler instance() // { // return instance; // } // // public int getQuestStatus(EntityPlayer player, String QuestName) // { // NBTTagCompound nbt = getQuestPlayer(player); // return nbt.getInteger(QuestName); // } // // public void setQuestStatus(EntityPlayer player, String questName, int questStatus) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(questName, questStatus); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestStarted(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 1); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestFinished(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 2); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void questFinishedReward(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 3); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt) // { // System.out.println("Added player: " + player.username + " to the QuestMap"); // getMap().put(player.username, nbt); // } // // public boolean isQuestActive(EntityPlayer player, String questName) // { // if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0) // return true; // return false; // } // // public NBTTagCompound getQuestPlayer(EntityPlayer player) // { // if(getMap().containsKey(player.username)) // { // System.out.println("Does have the player in there"); // return getMap().get(player.username); // } // return null; // } // // public HashMap<String, NBTTagCompound> getMap() // { // return questList; // } // // @SideOnly(Side.CLIENT) // public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) // { // HashMap<String, Integer> map = questProgress.get(player.username); // if(map == null) // map = new HashMap<String, Integer>(); // map.put(questName, questStatus); // questProgress.put(player.username, map); // } // // @SideOnly(Side.CLIENT) // public int getQuestStatusClient(EntityPlayer player, String questName) // { // HashMap<String, Integer> map; // if(questProgress.containsKey(player.username)) // { // map = questProgress.get(player.username); // } // else // map = new HashMap<String, Integer>(); // // if(map.containsKey(questName)) // return map.get(questName); // return 0; // } // // @SideOnly(Side.CLIENT) // public boolean isQuestActiveClient(EntityPlayer player, String questName) // { // if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0) // return true; // return false; // } // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.QuestHandler; import cpw.mods.fml.common.network.Player;
{ super(PacketType.QUESTDATA, false); } public PacketQuestData(String username, String questName, int questStatus) { super(PacketType.QUESTDATA, false); this.username = username; this.questName = questName; this.questStatus = questStatus; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.questName = data.readUTF(); this.questStatus = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeUTF(questName); dos.writeInt(questStatus); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java // public class QuestHandler // { // private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); // private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); // private static QuestHandler instance = new QuestHandler(); // // public QuestHandler(){} // // public static QuestHandler instance() // { // return instance; // } // // public int getQuestStatus(EntityPlayer player, String QuestName) // { // NBTTagCompound nbt = getQuestPlayer(player); // return nbt.getInteger(QuestName); // } // // public void setQuestStatus(EntityPlayer player, String questName, int questStatus) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(questName, questStatus); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestStarted(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 1); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestFinished(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 2); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void questFinishedReward(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 3); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt) // { // System.out.println("Added player: " + player.username + " to the QuestMap"); // getMap().put(player.username, nbt); // } // // public boolean isQuestActive(EntityPlayer player, String questName) // { // if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0) // return true; // return false; // } // // public NBTTagCompound getQuestPlayer(EntityPlayer player) // { // if(getMap().containsKey(player.username)) // { // System.out.println("Does have the player in there"); // return getMap().get(player.username); // } // return null; // } // // public HashMap<String, NBTTagCompound> getMap() // { // return questList; // } // // @SideOnly(Side.CLIENT) // public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) // { // HashMap<String, Integer> map = questProgress.get(player.username); // if(map == null) // map = new HashMap<String, Integer>(); // map.put(questName, questStatus); // questProgress.put(player.username, map); // } // // @SideOnly(Side.CLIENT) // public int getQuestStatusClient(EntityPlayer player, String questName) // { // HashMap<String, Integer> map; // if(questProgress.containsKey(player.username)) // { // map = questProgress.get(player.username); // } // else // map = new HashMap<String, Integer>(); // // if(map.containsKey(questName)) // return map.get(questName); // return 0; // } // // @SideOnly(Side.CLIENT) // public boolean isQuestActiveClient(EntityPlayer player, String questName) // { // if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0) // return true; // return false; // } // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketQuestData.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.QuestHandler; import cpw.mods.fml.common.network.Player; { super(PacketType.QUESTDATA, false); } public PacketQuestData(String username, String questName, int questStatus) { super(PacketType.QUESTDATA, false); this.username = username; this.questName = questName; this.questStatus = questStatus; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.questName = data.readUTF(); this.questStatus = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeUTF(questName); dos.writeInt(questStatus); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
QuestHandler.instance().setQuestStatus(thePlayer, questName, questStatus);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/handlers/EntityLivingHandler.java
// Path: Journey of Legends/aginsun/journey/universal/utils/ItemDropHelper.java // public class ItemDropHelper // { // public static World world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0); // public static boolean isHostileEntity(EntityLivingBase entity) // { // if ((entity instanceof IMob)) // { // if((entity instanceof EntitySlime)) // { // return false; // } // else // { // return true; // } // } // else // { // return false; // } // } // // public static void dropCoins(EntityLivingBase entity) // { // if (isHostileEntity(entity) && !world.isRemote) // { // for(int i = 0; i < 15; i++) // { // entity.dropItem(InitItems.ItemCoins.itemID, 1); // } // } // } // }
import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDeathEvent; import aginsun.journey.universal.utils.ItemDropHelper;
package aginsun.journey.universal.handlers; public class EntityLivingHandler { @ForgeSubscribe public void onEntityLivingDeath(LivingDeathEvent event) { if (event.source.getDamageType().equals("player")) {
// Path: Journey of Legends/aginsun/journey/universal/utils/ItemDropHelper.java // public class ItemDropHelper // { // public static World world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0); // public static boolean isHostileEntity(EntityLivingBase entity) // { // if ((entity instanceof IMob)) // { // if((entity instanceof EntitySlime)) // { // return false; // } // else // { // return true; // } // } // else // { // return false; // } // } // // public static void dropCoins(EntityLivingBase entity) // { // if (isHostileEntity(entity) && !world.isRemote) // { // for(int i = 0; i < 15; i++) // { // entity.dropItem(InitItems.ItemCoins.itemID, 1); // } // } // } // } // Path: Journey of Legends/aginsun/journey/universal/handlers/EntityLivingHandler.java import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDeathEvent; import aginsun.journey.universal.utils.ItemDropHelper; package aginsun.journey.universal.handlers; public class EntityLivingHandler { @ForgeSubscribe public void onEntityLivingDeath(LivingDeathEvent event) { if (event.source.getDamageType().equals("player")) {
ItemDropHelper.dropCoins(event.entityLiving);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/handlers/PacketHandler.java
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketJoL.java // public abstract class PacketJoL // { // public PacketType packetType; // public boolean isChunkDataPacket; // // public PacketJoL(PacketType packetType, boolean isChunkDataPacket) // { // this.packetType = packetType; // this.isChunkDataPacket = isChunkDataPacket; // } // // public byte[] populate() // { // ByteArrayOutputStream bos = new ByteArrayOutputStream(); // DataOutputStream dos = new DataOutputStream(bos); // // try{ // dos.writeByte(packetType.ordinal()); // this.writeData(dos); // }catch(IOException e){ // e.printStackTrace(); // } // // return bos.toByteArray(); // } // // public void readPopulate(DataInputStream data) { // // try { // this.readData(data); // } // catch (IOException e) { // e.printStackTrace(System.err); // } // } // // public abstract void readData(DataInputStream data) throws IOException; // // public abstract void writeData(DataOutputStream dos) throws IOException; // // public abstract void execute(INetworkManager network, Player player); // // public void setKey(int key){} // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // }
import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import aginsun.journey.universal.packets.PacketJoL; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player;
package aginsun.journey.universal.handlers; public class PacketHandler implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketJoL.java // public abstract class PacketJoL // { // public PacketType packetType; // public boolean isChunkDataPacket; // // public PacketJoL(PacketType packetType, boolean isChunkDataPacket) // { // this.packetType = packetType; // this.isChunkDataPacket = isChunkDataPacket; // } // // public byte[] populate() // { // ByteArrayOutputStream bos = new ByteArrayOutputStream(); // DataOutputStream dos = new DataOutputStream(bos); // // try{ // dos.writeByte(packetType.ordinal()); // this.writeData(dos); // }catch(IOException e){ // e.printStackTrace(); // } // // return bos.toByteArray(); // } // // public void readPopulate(DataInputStream data) { // // try { // this.readData(data); // } // catch (IOException e) { // e.printStackTrace(System.err); // } // } // // public abstract void readData(DataInputStream data) throws IOException; // // public abstract void writeData(DataOutputStream dos) throws IOException; // // public abstract void execute(INetworkManager network, Player player); // // public void setKey(int key){} // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // } // Path: Journey of Legends/aginsun/journey/universal/handlers/PacketHandler.java import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import aginsun.journey.universal.packets.PacketJoL; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; package aginsun.journey.universal.handlers; public class PacketHandler implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
PacketJoL packetToK = PacketType.buildPacket(packet.data);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/handlers/PacketHandler.java
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketJoL.java // public abstract class PacketJoL // { // public PacketType packetType; // public boolean isChunkDataPacket; // // public PacketJoL(PacketType packetType, boolean isChunkDataPacket) // { // this.packetType = packetType; // this.isChunkDataPacket = isChunkDataPacket; // } // // public byte[] populate() // { // ByteArrayOutputStream bos = new ByteArrayOutputStream(); // DataOutputStream dos = new DataOutputStream(bos); // // try{ // dos.writeByte(packetType.ordinal()); // this.writeData(dos); // }catch(IOException e){ // e.printStackTrace(); // } // // return bos.toByteArray(); // } // // public void readPopulate(DataInputStream data) { // // try { // this.readData(data); // } // catch (IOException e) { // e.printStackTrace(System.err); // } // } // // public abstract void readData(DataInputStream data) throws IOException; // // public abstract void writeData(DataOutputStream dos) throws IOException; // // public abstract void execute(INetworkManager network, Player player); // // public void setKey(int key){} // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // }
import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import aginsun.journey.universal.packets.PacketJoL; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player;
package aginsun.journey.universal.handlers; public class PacketHandler implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketJoL.java // public abstract class PacketJoL // { // public PacketType packetType; // public boolean isChunkDataPacket; // // public PacketJoL(PacketType packetType, boolean isChunkDataPacket) // { // this.packetType = packetType; // this.isChunkDataPacket = isChunkDataPacket; // } // // public byte[] populate() // { // ByteArrayOutputStream bos = new ByteArrayOutputStream(); // DataOutputStream dos = new DataOutputStream(bos); // // try{ // dos.writeByte(packetType.ordinal()); // this.writeData(dos); // }catch(IOException e){ // e.printStackTrace(); // } // // return bos.toByteArray(); // } // // public void readPopulate(DataInputStream data) { // // try { // this.readData(data); // } // catch (IOException e) { // e.printStackTrace(System.err); // } // } // // public abstract void readData(DataInputStream data) throws IOException; // // public abstract void writeData(DataOutputStream dos) throws IOException; // // public abstract void execute(INetworkManager network, Player player); // // public void setKey(int key){} // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // } // Path: Journey of Legends/aginsun/journey/universal/handlers/PacketHandler.java import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import aginsun.journey.universal.packets.PacketJoL; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; package aginsun.journey.universal.handlers; public class PacketHandler implements IPacketHandler { @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
PacketJoL packetToK = PacketType.buildPacket(packet.data);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketType.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Utils.java // public final class Utils // { // public static final String modID = "journeyoflegends"; // public static final String Version = "0.0.2A"; // public static final String Name = "Journey of Legends: The Start"; // }
import java.io.ByteArrayInputStream; import java.io.DataInputStream; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet250CustomPayload; import aginsun.journey.universal.utils.Utils;
packet = values()[selector].clazz.newInstance(); } catch (Exception e) { e.printStackTrace(System.err); } packet.readPopulate(dis); return packet; } public static PacketJoL buildPacket(PacketType type) { PacketJoL packet = null; try { packet = values()[type.ordinal()].clazz.newInstance(); } catch (Exception e) { e.printStackTrace(System.err); } return packet; } public static Packet populatePacket(PacketJoL packetToK) { byte[] data = packetToK.populate(); Packet250CustomPayload packet250 = new Packet250CustomPayload();
// Path: Journey of Legends/aginsun/journey/universal/utils/Utils.java // public final class Utils // { // public static final String modID = "journeyoflegends"; // public static final String Version = "0.0.2A"; // public static final String Name = "Journey of Legends: The Start"; // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java import java.io.ByteArrayInputStream; import java.io.DataInputStream; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet250CustomPayload; import aginsun.journey.universal.utils.Utils; packet = values()[selector].clazz.newInstance(); } catch (Exception e) { e.printStackTrace(System.err); } packet.readPopulate(dis); return packet; } public static PacketJoL buildPacket(PacketType type) { PacketJoL packet = null; try { packet = values()[type.ordinal()].clazz.newInstance(); } catch (Exception e) { e.printStackTrace(System.err); } return packet; } public static Packet populatePacket(PacketJoL packetToK) { byte[] data = packetToK.populate(); Packet250CustomPayload packet250 = new Packet250CustomPayload();
packet250.channel = Utils.modID;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/items/ItemRedClaw.java
// Path: Journey of Legends/aginsun/journey/universal/entities/EntityShuricken.java // public class EntityShuricken extends EntityThrowable // { // public EntityShuricken(World par1World) // { // super(par1World); // } // // public EntityShuricken(World par1World, EntityLivingBase par2EntityLiving) // { // super(par1World, par2EntityLiving); // } // // public EntityShuricken(World par1World, double par2, double par4, double par6) // { // super(par1World, par2, par4, par6); // } // // protected void onImpact(MovingObjectPosition par1MovingObjectPosition) // { // if (par1MovingObjectPosition.entityHit != null) // { // par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 2); // } // // if (!this.worldObj.isRemote) // { // this.setDead(); // } // } // }
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import aginsun.journey.universal.entities.EntityShuricken;
package aginsun.journey.universal.items; public class ItemRedClaw extends ItemClaw { public ItemRedClaw(int par1) { super(par1); this.maxStackSize = 1; this.setMaxDamage(-1); this.setCreativeTab(CreativeTabs.tabCombat); } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) {
// Path: Journey of Legends/aginsun/journey/universal/entities/EntityShuricken.java // public class EntityShuricken extends EntityThrowable // { // public EntityShuricken(World par1World) // { // super(par1World); // } // // public EntityShuricken(World par1World, EntityLivingBase par2EntityLiving) // { // super(par1World, par2EntityLiving); // } // // public EntityShuricken(World par1World, double par2, double par4, double par6) // { // super(par1World, par2, par4, par6); // } // // protected void onImpact(MovingObjectPosition par1MovingObjectPosition) // { // if (par1MovingObjectPosition.entityHit != null) // { // par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 2); // } // // if (!this.worldObj.isRemote) // { // this.setDead(); // } // } // } // Path: Journey of Legends/aginsun/journey/universal/items/ItemRedClaw.java import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import aginsun.journey.universal.entities.EntityShuricken; package aginsun.journey.universal.items; public class ItemRedClaw extends ItemClaw { public ItemRedClaw(int par1) { super(par1); this.maxStackSize = 1; this.setMaxDamage(-1); this.setCreativeTab(CreativeTabs.tabCombat); } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) {
par2World.spawnEntityInWorld(new EntityShuricken(par2World, par3EntityPlayer));
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/utils/ItemDropHelper.java
// Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // }
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntitySlime; import net.minecraft.entity.monster.IMob; import net.minecraft.world.World; import aginsun.journey.universal.items.InitItems; import cpw.mods.fml.common.FMLCommonHandler;
package aginsun.journey.universal.utils; public class ItemDropHelper { public static World world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0); public static boolean isHostileEntity(EntityLivingBase entity) { if ((entity instanceof IMob)) { if((entity instanceof EntitySlime)) { return false; } else { return true; } } else { return false; } } public static void dropCoins(EntityLivingBase entity) { if (isHostileEntity(entity) && !world.isRemote) { for(int i = 0; i < 15; i++) {
// Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // } // Path: Journey of Legends/aginsun/journey/universal/utils/ItemDropHelper.java import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntitySlime; import net.minecraft.entity.monster.IMob; import net.minecraft.world.World; import aginsun.journey.universal.items.InitItems; import cpw.mods.fml.common.FMLCommonHandler; package aginsun.journey.universal.utils; public class ItemDropHelper { public static World world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0); public static boolean isHostileEntity(EntityLivingBase entity) { if ((entity instanceof IMob)) { if((entity instanceof EntitySlime)) { return false; } else { return true; } } else { return false; } } public static void dropCoins(EntityLivingBase entity) { if (isHostileEntity(entity) && !world.isRemote) { for(int i = 0; i < 15; i++) {
entity.dropItem(InitItems.ItemCoins.itemID, 1);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/items/ItemJourneySword.java
// Path: Journey of Legends/aginsun/journey/server/api/LevelKeeper.java // public class LevelKeeper // { // private static HashMap<String, Integer> LevelMap = new HashMap<String, Integer>(); // private static HashMap<String, Integer> StatPointsMap = new HashMap<String, Integer>(); // // public static void setLevel(EntityPlayer player, int amount) // { // LevelMap.put(player.username, amount); // } // // public static int getLevel(EntityPlayer player) // { // if(LevelMap.containsKey(player.username)) // return LevelMap.get(player.username); // else // return 1; // } // // public static void addLevel(EntityPlayer player) // { // int x = getLevel(player); // x++; // setLevel(player, x); // } // // public static void setSP(EntityPlayer player, int amount) // { // StatPointsMap.put(player.username, amount); // } // // public static int getSP(EntityPlayer player) // { // if(StatPointsMap.containsKey(player.username)) // return StatPointsMap.get(player.username); // else // return 0; // } // // public static void addSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x += amount; // setSP(player, x); // } // // public static void decreaseSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x -= amount; // setSP(player, x); // } // } // // Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // }
import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraftforge.common.EnumHelper; import aginsun.journey.server.api.LevelKeeper; import aginsun.journey.server.api.RaceKeeper;
package aginsun.journey.universal.items; public class ItemJourneySword extends ItemSword { private static String name; private static int harvestLevel = 0; private static int maxUses; private static int efficiency = 0; private static int damage; private static int enchantability = 22; private String[] classes; private int level; public ItemJourneySword(int par1, String name, int maxUses, int damage, String[] classes, int level) { super(par1, EnumHelper.addToolMaterial(name, harvestLevel, maxUses, efficiency, damage, enchantability)); this.damage = damage; this.classes = classes; this.level = level; } public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { for(String string : classes)
// Path: Journey of Legends/aginsun/journey/server/api/LevelKeeper.java // public class LevelKeeper // { // private static HashMap<String, Integer> LevelMap = new HashMap<String, Integer>(); // private static HashMap<String, Integer> StatPointsMap = new HashMap<String, Integer>(); // // public static void setLevel(EntityPlayer player, int amount) // { // LevelMap.put(player.username, amount); // } // // public static int getLevel(EntityPlayer player) // { // if(LevelMap.containsKey(player.username)) // return LevelMap.get(player.username); // else // return 1; // } // // public static void addLevel(EntityPlayer player) // { // int x = getLevel(player); // x++; // setLevel(player, x); // } // // public static void setSP(EntityPlayer player, int amount) // { // StatPointsMap.put(player.username, amount); // } // // public static int getSP(EntityPlayer player) // { // if(StatPointsMap.containsKey(player.username)) // return StatPointsMap.get(player.username); // else // return 0; // } // // public static void addSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x += amount; // setSP(player, x); // } // // public static void decreaseSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x -= amount; // setSP(player, x); // } // } // // Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // } // Path: Journey of Legends/aginsun/journey/universal/items/ItemJourneySword.java import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraftforge.common.EnumHelper; import aginsun.journey.server.api.LevelKeeper; import aginsun.journey.server.api.RaceKeeper; package aginsun.journey.universal.items; public class ItemJourneySword extends ItemSword { private static String name; private static int harvestLevel = 0; private static int maxUses; private static int efficiency = 0; private static int damage; private static int enchantability = 22; private String[] classes; private int level; public ItemJourneySword(int par1, String name, int maxUses, int damage, String[] classes, int level) { super(par1, EnumHelper.addToolMaterial(name, harvestLevel, maxUses, efficiency, damage, enchantability)); this.damage = damage; this.classes = classes; this.level = level; } public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { for(String string : classes)
if(string.equals(RaceKeeper.getClass(player)))
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/items/ItemJourneySword.java
// Path: Journey of Legends/aginsun/journey/server/api/LevelKeeper.java // public class LevelKeeper // { // private static HashMap<String, Integer> LevelMap = new HashMap<String, Integer>(); // private static HashMap<String, Integer> StatPointsMap = new HashMap<String, Integer>(); // // public static void setLevel(EntityPlayer player, int amount) // { // LevelMap.put(player.username, amount); // } // // public static int getLevel(EntityPlayer player) // { // if(LevelMap.containsKey(player.username)) // return LevelMap.get(player.username); // else // return 1; // } // // public static void addLevel(EntityPlayer player) // { // int x = getLevel(player); // x++; // setLevel(player, x); // } // // public static void setSP(EntityPlayer player, int amount) // { // StatPointsMap.put(player.username, amount); // } // // public static int getSP(EntityPlayer player) // { // if(StatPointsMap.containsKey(player.username)) // return StatPointsMap.get(player.username); // else // return 0; // } // // public static void addSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x += amount; // setSP(player, x); // } // // public static void decreaseSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x -= amount; // setSP(player, x); // } // } // // Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // }
import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraftforge.common.EnumHelper; import aginsun.journey.server.api.LevelKeeper; import aginsun.journey.server.api.RaceKeeper;
package aginsun.journey.universal.items; public class ItemJourneySword extends ItemSword { private static String name; private static int harvestLevel = 0; private static int maxUses; private static int efficiency = 0; private static int damage; private static int enchantability = 22; private String[] classes; private int level; public ItemJourneySword(int par1, String name, int maxUses, int damage, String[] classes, int level) { super(par1, EnumHelper.addToolMaterial(name, harvestLevel, maxUses, efficiency, damage, enchantability)); this.damage = damage; this.classes = classes; this.level = level; } public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { for(String string : classes) if(string.equals(RaceKeeper.getClass(player)))
// Path: Journey of Legends/aginsun/journey/server/api/LevelKeeper.java // public class LevelKeeper // { // private static HashMap<String, Integer> LevelMap = new HashMap<String, Integer>(); // private static HashMap<String, Integer> StatPointsMap = new HashMap<String, Integer>(); // // public static void setLevel(EntityPlayer player, int amount) // { // LevelMap.put(player.username, amount); // } // // public static int getLevel(EntityPlayer player) // { // if(LevelMap.containsKey(player.username)) // return LevelMap.get(player.username); // else // return 1; // } // // public static void addLevel(EntityPlayer player) // { // int x = getLevel(player); // x++; // setLevel(player, x); // } // // public static void setSP(EntityPlayer player, int amount) // { // StatPointsMap.put(player.username, amount); // } // // public static int getSP(EntityPlayer player) // { // if(StatPointsMap.containsKey(player.username)) // return StatPointsMap.get(player.username); // else // return 0; // } // // public static void addSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x += amount; // setSP(player, x); // } // // public static void decreaseSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x -= amount; // setSP(player, x); // } // } // // Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // } // Path: Journey of Legends/aginsun/journey/universal/items/ItemJourneySword.java import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraftforge.common.EnumHelper; import aginsun.journey.server.api.LevelKeeper; import aginsun.journey.server.api.RaceKeeper; package aginsun.journey.universal.items; public class ItemJourneySword extends ItemSword { private static String name; private static int harvestLevel = 0; private static int maxUses; private static int efficiency = 0; private static int damage; private static int enchantability = 22; private String[] classes; private int level; public ItemJourneySword(int par1, String name, int maxUses, int damage, String[] classes, int level) { super(par1, EnumHelper.addToolMaterial(name, harvestLevel, maxUses, efficiency, damage, enchantability)); this.damage = damage; this.classes = classes; this.level = level; } public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { for(String string : classes) if(string.equals(RaceKeeper.getClass(player)))
if(level <= LevelKeeper.getLevel(player))
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/client/guis/GuiQuestProgress.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // }
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import aginsun.journey.universal.utils.Quest;
package aginsun.journey.client.guis; public class GuiQuestProgress extends GuiScreen {
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // } // Path: Journey of Legends/aginsun/journey/client/guis/GuiQuestProgress.java import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import aginsun.journey.universal.utils.Quest; package aginsun.journey.client.guis; public class GuiQuestProgress extends GuiScreen {
private Quest quest;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/entities/EntityFarmerKeeper.java
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // }
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import aginsun.journey.server.api.GoldKeeper;
package aginsun.journey.universal.entities; public class EntityFarmerKeeper extends EntityCreature { private World worldObj; private boolean freebread; private ItemStack defaultHeldItem;
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // Path: Journey of Legends/aginsun/journey/universal/entities/EntityFarmerKeeper.java import net.minecraft.entity.EntityCreature; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import aginsun.journey.server.api.GoldKeeper; package aginsun.journey.universal.entities; public class EntityFarmerKeeper extends EntityCreature { private World worldObj; private boolean freebread; private ItemStack defaultHeldItem;
public static GoldKeeper gold;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/client/guis/GuiTrades.java
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // // Path: Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java // public class TradingHandler // { // private HashMap<String, ArrayList<Trade>> tradeList = new HashMap<String, ArrayList<Trade>>(); // // private static TradingHandler instance = new TradingHandler(); // // public static TradingHandler getInstance() // { // return instance; // } // // public void addTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.add(trade); // setTradesPlayer(player, tradeList); // } // // public void removeTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.remove(trade); // setTradesPlayer(player, tradeList); // } // // public void setTradesPlayer(EntityPlayer player, ArrayList<Trade> tradeList) // { // this.tradeList.put(player.username, tradeList); // } // // public ArrayList<Trade> getTradesPlayer(EntityPlayer player) // { // return tradeList.get(player.username); // } // // public Item getItemSelling(Trade trade) // { // return trade.selling; // } // // public Item getItemBuying(Trade trade) // { // return trade.buying; // } // // public int getGoldAmount(Trade trade) // { // return trade.gold; // } // // public ArrayList<Trade> getAllTrades() // { // ArrayList<Trade> tradingList = new ArrayList<Trade>(); // // for(ArrayList<Trade> list : tradeList.values()) // { // for(Trade trade : list) // { // tradingList.add(trade); // } // } // return tradingList; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public enum EnumType // { // SELLING, BUYING; // }
import java.util.ArrayList; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.GoldKeeper; import aginsun.journey.server.handlers.TradingHandler; import aginsun.journey.universal.utils.Trade; import aginsun.journey.universal.utils.Trade.EnumType;
package aginsun.journey.client.guis; public class GuiTrades extends GuiScreen { private int pages;
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // // Path: Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java // public class TradingHandler // { // private HashMap<String, ArrayList<Trade>> tradeList = new HashMap<String, ArrayList<Trade>>(); // // private static TradingHandler instance = new TradingHandler(); // // public static TradingHandler getInstance() // { // return instance; // } // // public void addTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.add(trade); // setTradesPlayer(player, tradeList); // } // // public void removeTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.remove(trade); // setTradesPlayer(player, tradeList); // } // // public void setTradesPlayer(EntityPlayer player, ArrayList<Trade> tradeList) // { // this.tradeList.put(player.username, tradeList); // } // // public ArrayList<Trade> getTradesPlayer(EntityPlayer player) // { // return tradeList.get(player.username); // } // // public Item getItemSelling(Trade trade) // { // return trade.selling; // } // // public Item getItemBuying(Trade trade) // { // return trade.buying; // } // // public int getGoldAmount(Trade trade) // { // return trade.gold; // } // // public ArrayList<Trade> getAllTrades() // { // ArrayList<Trade> tradingList = new ArrayList<Trade>(); // // for(ArrayList<Trade> list : tradeList.values()) // { // for(Trade trade : list) // { // tradingList.add(trade); // } // } // return tradingList; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public enum EnumType // { // SELLING, BUYING; // } // Path: Journey of Legends/aginsun/journey/client/guis/GuiTrades.java import java.util.ArrayList; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.GoldKeeper; import aginsun.journey.server.handlers.TradingHandler; import aginsun.journey.universal.utils.Trade; import aginsun.journey.universal.utils.Trade.EnumType; package aginsun.journey.client.guis; public class GuiTrades extends GuiScreen { private int pages;
ArrayList<Trade> tradeList;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/client/guis/GuiTrades.java
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // // Path: Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java // public class TradingHandler // { // private HashMap<String, ArrayList<Trade>> tradeList = new HashMap<String, ArrayList<Trade>>(); // // private static TradingHandler instance = new TradingHandler(); // // public static TradingHandler getInstance() // { // return instance; // } // // public void addTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.add(trade); // setTradesPlayer(player, tradeList); // } // // public void removeTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.remove(trade); // setTradesPlayer(player, tradeList); // } // // public void setTradesPlayer(EntityPlayer player, ArrayList<Trade> tradeList) // { // this.tradeList.put(player.username, tradeList); // } // // public ArrayList<Trade> getTradesPlayer(EntityPlayer player) // { // return tradeList.get(player.username); // } // // public Item getItemSelling(Trade trade) // { // return trade.selling; // } // // public Item getItemBuying(Trade trade) // { // return trade.buying; // } // // public int getGoldAmount(Trade trade) // { // return trade.gold; // } // // public ArrayList<Trade> getAllTrades() // { // ArrayList<Trade> tradingList = new ArrayList<Trade>(); // // for(ArrayList<Trade> list : tradeList.values()) // { // for(Trade trade : list) // { // tradingList.add(trade); // } // } // return tradingList; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public enum EnumType // { // SELLING, BUYING; // }
import java.util.ArrayList; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.GoldKeeper; import aginsun.journey.server.handlers.TradingHandler; import aginsun.journey.universal.utils.Trade; import aginsun.journey.universal.utils.Trade.EnumType;
package aginsun.journey.client.guis; public class GuiTrades extends GuiScreen { private int pages; ArrayList<Trade> tradeList; public GuiTrades() {
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // // Path: Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java // public class TradingHandler // { // private HashMap<String, ArrayList<Trade>> tradeList = new HashMap<String, ArrayList<Trade>>(); // // private static TradingHandler instance = new TradingHandler(); // // public static TradingHandler getInstance() // { // return instance; // } // // public void addTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.add(trade); // setTradesPlayer(player, tradeList); // } // // public void removeTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.remove(trade); // setTradesPlayer(player, tradeList); // } // // public void setTradesPlayer(EntityPlayer player, ArrayList<Trade> tradeList) // { // this.tradeList.put(player.username, tradeList); // } // // public ArrayList<Trade> getTradesPlayer(EntityPlayer player) // { // return tradeList.get(player.username); // } // // public Item getItemSelling(Trade trade) // { // return trade.selling; // } // // public Item getItemBuying(Trade trade) // { // return trade.buying; // } // // public int getGoldAmount(Trade trade) // { // return trade.gold; // } // // public ArrayList<Trade> getAllTrades() // { // ArrayList<Trade> tradingList = new ArrayList<Trade>(); // // for(ArrayList<Trade> list : tradeList.values()) // { // for(Trade trade : list) // { // tradingList.add(trade); // } // } // return tradingList; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public enum EnumType // { // SELLING, BUYING; // } // Path: Journey of Legends/aginsun/journey/client/guis/GuiTrades.java import java.util.ArrayList; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.GoldKeeper; import aginsun.journey.server.handlers.TradingHandler; import aginsun.journey.universal.utils.Trade; import aginsun.journey.universal.utils.Trade.EnumType; package aginsun.journey.client.guis; public class GuiTrades extends GuiScreen { private int pages; ArrayList<Trade> tradeList; public GuiTrades() {
tradeList = TradingHandler.getInstance().getAllTrades();
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/client/guis/GuiTrades.java
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // // Path: Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java // public class TradingHandler // { // private HashMap<String, ArrayList<Trade>> tradeList = new HashMap<String, ArrayList<Trade>>(); // // private static TradingHandler instance = new TradingHandler(); // // public static TradingHandler getInstance() // { // return instance; // } // // public void addTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.add(trade); // setTradesPlayer(player, tradeList); // } // // public void removeTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.remove(trade); // setTradesPlayer(player, tradeList); // } // // public void setTradesPlayer(EntityPlayer player, ArrayList<Trade> tradeList) // { // this.tradeList.put(player.username, tradeList); // } // // public ArrayList<Trade> getTradesPlayer(EntityPlayer player) // { // return tradeList.get(player.username); // } // // public Item getItemSelling(Trade trade) // { // return trade.selling; // } // // public Item getItemBuying(Trade trade) // { // return trade.buying; // } // // public int getGoldAmount(Trade trade) // { // return trade.gold; // } // // public ArrayList<Trade> getAllTrades() // { // ArrayList<Trade> tradingList = new ArrayList<Trade>(); // // for(ArrayList<Trade> list : tradeList.values()) // { // for(Trade trade : list) // { // tradingList.add(trade); // } // } // return tradingList; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public enum EnumType // { // SELLING, BUYING; // }
import java.util.ArrayList; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.GoldKeeper; import aginsun.journey.server.handlers.TradingHandler; import aginsun.journey.universal.utils.Trade; import aginsun.journey.universal.utils.Trade.EnumType;
package aginsun.journey.client.guis; public class GuiTrades extends GuiScreen { private int pages; ArrayList<Trade> tradeList; public GuiTrades() { tradeList = TradingHandler.getInstance().getAllTrades(); pages = Math.round(tradeList.size() / 8); } public void initGui() { buttonList.clear(); buttonList.add(new GuiButton(1, width / 2, height / 2, 120, 20, "Next")); buttonList.add(new GuiButton(2, width / 2, height / 2, 120, 20, "previous")); for(int i = pages * 8; i < tradeList.size(); i++) { int trade = i + 2;
// Path: Journey of Legends/aginsun/journey/server/api/GoldKeeper.java // public class GoldKeeper // { // private static HashMap<String, Integer> GoldValues = new HashMap<String, Integer>(); // // public static int getGoldTotal(EntityPlayer player) // { // if(!GoldValues.containsKey(player.username)) // { // return 0; // } // return GoldValues.get(player.username); // } // // public static int getGoldTotal(String username) // { // if(!GoldValues.containsKey(username)) // { // return 0; // } // return GoldValues.get(username); // } // // public static void setGold(EntityPlayer player, int GoldValue) // { // GoldValues.put(player.username, GoldValue); // } // // // /** // * Adds 1 gold coin // * @param player // */ // public static void addGold(EntityPlayer player) // { // int i = getGoldTotal(player); // i++; // setGold(player, i); // } // // public static void addGold(String username, int amount) // { // int i = GoldValues.get(username); // i += amount; // GoldValues.put(username, i); // } // // /** // * Add a specific amount of gold // * // * @param player // * @param amount // */ // public static void addGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i += amount; // setGold(player, i); // } // // /** // * Remove a specific amount of gold coins // * @param player // * @param amount // */ // public static void removeGold(EntityPlayer player, int amount) // { // int i = getGoldTotal(player); // i -= amount; // setGold(player, i); // } // } // // Path: Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java // public class TradingHandler // { // private HashMap<String, ArrayList<Trade>> tradeList = new HashMap<String, ArrayList<Trade>>(); // // private static TradingHandler instance = new TradingHandler(); // // public static TradingHandler getInstance() // { // return instance; // } // // public void addTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.add(trade); // setTradesPlayer(player, tradeList); // } // // public void removeTrade(EntityPlayer player, Trade trade) // { // ArrayList<Trade> tradeList = getTradesPlayer(player); // tradeList.remove(trade); // setTradesPlayer(player, tradeList); // } // // public void setTradesPlayer(EntityPlayer player, ArrayList<Trade> tradeList) // { // this.tradeList.put(player.username, tradeList); // } // // public ArrayList<Trade> getTradesPlayer(EntityPlayer player) // { // return tradeList.get(player.username); // } // // public Item getItemSelling(Trade trade) // { // return trade.selling; // } // // public Item getItemBuying(Trade trade) // { // return trade.buying; // } // // public int getGoldAmount(Trade trade) // { // return trade.gold; // } // // public ArrayList<Trade> getAllTrades() // { // ArrayList<Trade> tradingList = new ArrayList<Trade>(); // // for(ArrayList<Trade> list : tradeList.values()) // { // for(Trade trade : list) // { // tradingList.add(trade); // } // } // return tradingList; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // } // // Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public enum EnumType // { // SELLING, BUYING; // } // Path: Journey of Legends/aginsun/journey/client/guis/GuiTrades.java import java.util.ArrayList; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.GoldKeeper; import aginsun.journey.server.handlers.TradingHandler; import aginsun.journey.universal.utils.Trade; import aginsun.journey.universal.utils.Trade.EnumType; package aginsun.journey.client.guis; public class GuiTrades extends GuiScreen { private int pages; ArrayList<Trade> tradeList; public GuiTrades() { tradeList = TradingHandler.getInstance().getAllTrades(); pages = Math.round(tradeList.size() / 8); } public void initGui() { buttonList.clear(); buttonList.add(new GuiButton(1, width / 2, height / 2, 120, 20, "Next")); buttonList.add(new GuiButton(2, width / 2, height / 2, 120, 20, "previous")); for(int i = pages * 8; i < tradeList.size(); i++) { int trade = i + 2;
if(tradeList.get(i).enumType == EnumType.BUYING)
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/items/InitItems.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Utils.java // public final class Utils // { // public static final String modID = "journeyoflegends"; // public static final String Version = "0.0.2A"; // public static final String Name = "Journey of Legends: The Start"; // }
import net.minecraft.item.Item; import aginsun.journey.universal.utils.Utils; import cpw.mods.fml.common.registry.LanguageRegistry;
package aginsun.journey.universal.items; public class InitItems {
// Path: Journey of Legends/aginsun/journey/universal/utils/Utils.java // public final class Utils // { // public static final String modID = "journeyoflegends"; // public static final String Version = "0.0.2A"; // public static final String Name = "Journey of Legends: The Start"; // } // Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java import net.minecraft.item.Item; import aginsun.journey.universal.utils.Utils; import cpw.mods.fml.common.registry.LanguageRegistry; package aginsun.journey.universal.items; public class InitItems {
public static String ModID = Utils.modID;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/items/ItemShuricken.java
// Path: Journey of Legends/aginsun/journey/universal/entities/EntityShuricken.java // public class EntityShuricken extends EntityThrowable // { // public EntityShuricken(World par1World) // { // super(par1World); // } // // public EntityShuricken(World par1World, EntityLivingBase par2EntityLiving) // { // super(par1World, par2EntityLiving); // } // // public EntityShuricken(World par1World, double par2, double par4, double par6) // { // super(par1World, par2, par4, par6); // } // // protected void onImpact(MovingObjectPosition par1MovingObjectPosition) // { // if (par1MovingObjectPosition.entityHit != null) // { // par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 2); // } // // if (!this.worldObj.isRemote) // { // this.setDead(); // } // } // }
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import aginsun.journey.universal.entities.EntityShuricken; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package aginsun.journey.universal.items; public class ItemShuricken extends Item { public ItemShuricken(int par1) { super(par1); this.setCreativeTab(CreativeTabs.tabCombat); } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) {
// Path: Journey of Legends/aginsun/journey/universal/entities/EntityShuricken.java // public class EntityShuricken extends EntityThrowable // { // public EntityShuricken(World par1World) // { // super(par1World); // } // // public EntityShuricken(World par1World, EntityLivingBase par2EntityLiving) // { // super(par1World, par2EntityLiving); // } // // public EntityShuricken(World par1World, double par2, double par4, double par6) // { // super(par1World, par2, par4, par6); // } // // protected void onImpact(MovingObjectPosition par1MovingObjectPosition) // { // if (par1MovingObjectPosition.entityHit != null) // { // par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 2); // } // // if (!this.worldObj.isRemote) // { // this.setDead(); // } // } // } // Path: Journey of Legends/aginsun/journey/universal/items/ItemShuricken.java import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import aginsun.journey.universal.entities.EntityShuricken; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package aginsun.journey.universal.items; public class ItemShuricken extends Item { public ItemShuricken(int par1) { super(par1); this.setCreativeTab(CreativeTabs.tabCombat); } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) {
par2World.spawnEntityInWorld(new EntityShuricken(par2World, par3EntityPlayer));
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketQuestDataClient.java
// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java // public class QuestHandler // { // private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); // private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); // private static QuestHandler instance = new QuestHandler(); // // public QuestHandler(){} // // public static QuestHandler instance() // { // return instance; // } // // public int getQuestStatus(EntityPlayer player, String QuestName) // { // NBTTagCompound nbt = getQuestPlayer(player); // return nbt.getInteger(QuestName); // } // // public void setQuestStatus(EntityPlayer player, String questName, int questStatus) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(questName, questStatus); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestStarted(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 1); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestFinished(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 2); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void questFinishedReward(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 3); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt) // { // System.out.println("Added player: " + player.username + " to the QuestMap"); // getMap().put(player.username, nbt); // } // // public boolean isQuestActive(EntityPlayer player, String questName) // { // if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0) // return true; // return false; // } // // public NBTTagCompound getQuestPlayer(EntityPlayer player) // { // if(getMap().containsKey(player.username)) // { // System.out.println("Does have the player in there"); // return getMap().get(player.username); // } // return null; // } // // public HashMap<String, NBTTagCompound> getMap() // { // return questList; // } // // @SideOnly(Side.CLIENT) // public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) // { // HashMap<String, Integer> map = questProgress.get(player.username); // if(map == null) // map = new HashMap<String, Integer>(); // map.put(questName, questStatus); // questProgress.put(player.username, map); // } // // @SideOnly(Side.CLIENT) // public int getQuestStatusClient(EntityPlayer player, String questName) // { // HashMap<String, Integer> map; // if(questProgress.containsKey(player.username)) // { // map = questProgress.get(player.username); // } // else // map = new HashMap<String, Integer>(); // // if(map.containsKey(questName)) // return map.get(questName); // return 0; // } // // @SideOnly(Side.CLIENT) // public boolean isQuestActiveClient(EntityPlayer player, String questName) // { // if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0) // return true; // return false; // } // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.QuestHandler; import cpw.mods.fml.common.network.Player;
{ super(PacketType.QUESTDATACLIENT, false); } public PacketQuestDataClient(String username, String questName, int questStatus) { super(PacketType.QUESTDATACLIENT, false); this.username = username; this.questName = questName; this.questStatus = questStatus; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.questName = data.readUTF(); this.questStatus = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeUTF(questName); dos.writeInt(questStatus); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java // public class QuestHandler // { // private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); // private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); // private static QuestHandler instance = new QuestHandler(); // // public QuestHandler(){} // // public static QuestHandler instance() // { // return instance; // } // // public int getQuestStatus(EntityPlayer player, String QuestName) // { // NBTTagCompound nbt = getQuestPlayer(player); // return nbt.getInteger(QuestName); // } // // public void setQuestStatus(EntityPlayer player, String questName, int questStatus) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(questName, questStatus); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestStarted(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 1); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestFinished(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 2); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void questFinishedReward(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 3); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt) // { // System.out.println("Added player: " + player.username + " to the QuestMap"); // getMap().put(player.username, nbt); // } // // public boolean isQuestActive(EntityPlayer player, String questName) // { // if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0) // return true; // return false; // } // // public NBTTagCompound getQuestPlayer(EntityPlayer player) // { // if(getMap().containsKey(player.username)) // { // System.out.println("Does have the player in there"); // return getMap().get(player.username); // } // return null; // } // // public HashMap<String, NBTTagCompound> getMap() // { // return questList; // } // // @SideOnly(Side.CLIENT) // public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) // { // HashMap<String, Integer> map = questProgress.get(player.username); // if(map == null) // map = new HashMap<String, Integer>(); // map.put(questName, questStatus); // questProgress.put(player.username, map); // } // // @SideOnly(Side.CLIENT) // public int getQuestStatusClient(EntityPlayer player, String questName) // { // HashMap<String, Integer> map; // if(questProgress.containsKey(player.username)) // { // map = questProgress.get(player.username); // } // else // map = new HashMap<String, Integer>(); // // if(map.containsKey(questName)) // return map.get(questName); // return 0; // } // // @SideOnly(Side.CLIENT) // public boolean isQuestActiveClient(EntityPlayer player, String questName) // { // if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0) // return true; // return false; // } // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketQuestDataClient.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.QuestHandler; import cpw.mods.fml.common.network.Player; { super(PacketType.QUESTDATACLIENT, false); } public PacketQuestDataClient(String username, String questName, int questStatus) { super(PacketType.QUESTDATACLIENT, false); this.username = username; this.questName = questName; this.questStatus = questStatus; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.questName = data.readUTF(); this.questStatus = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeUTF(questName); dos.writeInt(questStatus); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
QuestHandler.instance().setQuestStatusClient(thePlayer, questName, questStatus);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // }
import java.util.ArrayList; import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import aginsun.journey.universal.utils.Trade;
package aginsun.journey.server.handlers; public class TradingHandler {
// Path: Journey of Legends/aginsun/journey/universal/utils/Trade.java // public class Trade // { // public Item selling, buying; // public int gold; // public EntityPlayer username; // public EnumType enumType; // // public Trade(Item selling, Item buying, int gold, EnumType enumType, EntityPlayer username) // { // this.selling = selling; // this.buying = buying; // this.gold = gold; // this.enumType = enumType; // this.username = username; // } // // public enum EnumType // { // SELLING, BUYING; // } // } // Path: Journey of Legends/aginsun/journey/server/handlers/TradingHandler.java import java.util.ArrayList; import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import aginsun.journey.universal.utils.Trade; package aginsun.journey.server.handlers; public class TradingHandler {
private HashMap<String, ArrayList<Trade>> tradeList = new HashMap<String, ArrayList<Trade>>();
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/server/handlers/PartyHandler.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Party.java // public class Party // { // public List playerList; // public Color color; // public String partyName, partyLeaderUsername; // // public Party(String partyName, String partyLeaderUsername, List playerList, Color color) // { // this.partyName = partyName; // this.partyLeaderUsername = partyLeaderUsername; // this.playerList = playerList; // this.color = color; // } // }
import java.awt.Color; import java.util.HashMap; import java.util.List; import aginsun.journey.universal.utils.Party;
package aginsun.journey.server.handlers; public class PartyHandler {
// Path: Journey of Legends/aginsun/journey/universal/utils/Party.java // public class Party // { // public List playerList; // public Color color; // public String partyName, partyLeaderUsername; // // public Party(String partyName, String partyLeaderUsername, List playerList, Color color) // { // this.partyName = partyName; // this.partyLeaderUsername = partyLeaderUsername; // this.playerList = playerList; // this.color = color; // } // } // Path: Journey of Legends/aginsun/journey/server/handlers/PartyHandler.java import java.awt.Color; import java.util.HashMap; import java.util.List; import aginsun.journey.universal.utils.Party; package aginsun.journey.server.handlers; public class PartyHandler {
private HashMap<String, Party> map = new HashMap<String, Party>();
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketRace.java
// Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.RaceKeeper; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
public PacketRace(String username, String race) { super(PacketType.RACE, false); this.username = username; this.race = race; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.race = data.readUTF(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeUTF(race); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player; setValues(thePlayer); } @SideOnly(Side.CLIENT) public void setValues(EntityPlayer player) {
// Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketRace.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.RaceKeeper; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public PacketRace(String username, String race) { super(PacketType.RACE, false); this.username = username; this.race = race; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.race = data.readUTF(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeUTF(race); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player; setValues(thePlayer); } @SideOnly(Side.CLIENT) public void setValues(EntityPlayer player) {
RaceKeeper.setClass(player, race);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/quests/QuestAdventureStart.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // } // // Path: Journey of Legends/aginsun/journey/universal/utils/QuestType.java // public enum QuestType // { // GATHERING("Gathering"), // HUNTING("Hunting"), // STUFF("Stuff"); // // // private QuestType(String QuestType) // { // // } // }
import net.minecraft.item.ItemStack; import aginsun.journey.universal.utils.Quest; import aginsun.journey.universal.utils.QuestType;
package aginsun.journey.universal.quests; public class QuestAdventureStart extends Quest { private static String[] StartLines = {""}; private static String[] EndLines = {"And so the first quest is finished, talk to me again for the second quest!"}; private static String[] ProgressLines = {""}; private static String[] QuestName = {"The Start"}; private static int[] RewardXP = {100}; private static int[] RewardGold = {100}; private static ItemStack[] itemstack = {null}; private static String[][] questDiscription = {new String[]{"The start of your adventure lies here", "You are on your way to becoming a legend"}}; public QuestAdventureStart(int QuestNumber, int index) { super(QuestNumber, index, StartLines, EndLines, ProgressLines, QuestName, RewardXP, RewardGold, itemstack, questDiscription); } @Override
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // } // // Path: Journey of Legends/aginsun/journey/universal/utils/QuestType.java // public enum QuestType // { // GATHERING("Gathering"), // HUNTING("Hunting"), // STUFF("Stuff"); // // // private QuestType(String QuestType) // { // // } // } // Path: Journey of Legends/aginsun/journey/universal/quests/QuestAdventureStart.java import net.minecraft.item.ItemStack; import aginsun.journey.universal.utils.Quest; import aginsun.journey.universal.utils.QuestType; package aginsun.journey.universal.quests; public class QuestAdventureStart extends Quest { private static String[] StartLines = {""}; private static String[] EndLines = {"And so the first quest is finished, talk to me again for the second quest!"}; private static String[] ProgressLines = {""}; private static String[] QuestName = {"The Start"}; private static int[] RewardXP = {100}; private static int[] RewardGold = {100}; private static ItemStack[] itemstack = {null}; private static String[][] questDiscription = {new String[]{"The start of your adventure lies here", "You are on your way to becoming a legend"}}; public QuestAdventureStart(int QuestNumber, int index) { super(QuestNumber, index, StartLines, EndLines, ProgressLines, QuestName, RewardXP, RewardGold, itemstack, questDiscription); } @Override
public QuestType getQuestType()
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketLevel.java
// Path: Journey of Legends/aginsun/journey/server/api/LevelKeeper.java // public class LevelKeeper // { // private static HashMap<String, Integer> LevelMap = new HashMap<String, Integer>(); // private static HashMap<String, Integer> StatPointsMap = new HashMap<String, Integer>(); // // public static void setLevel(EntityPlayer player, int amount) // { // LevelMap.put(player.username, amount); // } // // public static int getLevel(EntityPlayer player) // { // if(LevelMap.containsKey(player.username)) // return LevelMap.get(player.username); // else // return 1; // } // // public static void addLevel(EntityPlayer player) // { // int x = getLevel(player); // x++; // setLevel(player, x); // } // // public static void setSP(EntityPlayer player, int amount) // { // StatPointsMap.put(player.username, amount); // } // // public static int getSP(EntityPlayer player) // { // if(StatPointsMap.containsKey(player.username)) // return StatPointsMap.get(player.username); // else // return 0; // } // // public static void addSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x += amount; // setSP(player, x); // } // // public static void decreaseSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x -= amount; // setSP(player, x); // } // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.LevelKeeper; import cpw.mods.fml.common.network.Player;
public PacketLevel(String username, int level, int SP) { super(PacketType.LEVEL, false); this.username = username; this.level = level; this.SP = SP; } @Override public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.level = data.readInt(); this.SP = data.readInt(); } @Override public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(level); dos.writeInt(SP); } @Override public void execute(INetworkManager network, Player thePlayer) { EntityPlayer player = (EntityPlayer) thePlayer;
// Path: Journey of Legends/aginsun/journey/server/api/LevelKeeper.java // public class LevelKeeper // { // private static HashMap<String, Integer> LevelMap = new HashMap<String, Integer>(); // private static HashMap<String, Integer> StatPointsMap = new HashMap<String, Integer>(); // // public static void setLevel(EntityPlayer player, int amount) // { // LevelMap.put(player.username, amount); // } // // public static int getLevel(EntityPlayer player) // { // if(LevelMap.containsKey(player.username)) // return LevelMap.get(player.username); // else // return 1; // } // // public static void addLevel(EntityPlayer player) // { // int x = getLevel(player); // x++; // setLevel(player, x); // } // // public static void setSP(EntityPlayer player, int amount) // { // StatPointsMap.put(player.username, amount); // } // // public static int getSP(EntityPlayer player) // { // if(StatPointsMap.containsKey(player.username)) // return StatPointsMap.get(player.username); // else // return 0; // } // // public static void addSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x += amount; // setSP(player, x); // } // // public static void decreaseSP(EntityPlayer player, int amount) // { // int x = getSP(player); // x -= amount; // setSP(player, x); // } // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketLevel.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.LevelKeeper; import cpw.mods.fml.common.network.Player; public PacketLevel(String username, int level, int SP) { super(PacketType.LEVEL, false); this.username = username; this.level = level; this.SP = SP; } @Override public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.level = data.readInt(); this.SP = data.readInt(); } @Override public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(level); dos.writeInt(SP); } @Override public void execute(INetworkManager network, Player thePlayer) { EntityPlayer player = (EntityPlayer) thePlayer;
LevelKeeper.setLevel(player, level);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/client/guis/GuiRaceSelect.java
// Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // }
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.RaceKeeper; import cpw.mods.fml.client.FMLClientHandler;
package aginsun.journey.client.guis; public class GuiRaceSelect extends GuiScreen { public EntityPlayer player; public int buttonSelected;
// Path: Journey of Legends/aginsun/journey/server/api/RaceKeeper.java // public class RaceKeeper // { // public static HashMap<String, String> Race = new HashMap<String, String>(); // // public static String getClass(EntityPlayer player) // { // if(Race.containsKey(player.username)) // return Race.get(player.username); // else // return "Beginner"; // } // // public static void setClass(EntityPlayer player, String race) // { // Race.put(player.username, race); // } // } // Path: Journey of Legends/aginsun/journey/client/guis/GuiRaceSelect.java import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import aginsun.journey.server.api.RaceKeeper; import cpw.mods.fml.client.FMLClientHandler; package aginsun.journey.client.guis; public class GuiRaceSelect extends GuiScreen { public EntityPlayer player; public int buttonSelected;
public RaceKeeper race;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/quests/QuestFarmer.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // } // // Path: Journey of Legends/aginsun/journey/universal/utils/QuestType.java // public enum QuestType // { // GATHERING("Gathering"), // HUNTING("Hunting"), // STUFF("Stuff"); // // // private QuestType(String QuestType) // { // // } // }
import net.minecraft.item.ItemStack; import aginsun.journey.universal.utils.Quest; import aginsun.journey.universal.utils.QuestType;
package aginsun.journey.universal.quests; public class QuestFarmer extends Quest { private static String[] StartLines = {""}; private static String[] EndLines = {}; private static String[] ProgressLines = {}; private static String[] QuestName = {}; private static int[] RewardXP = {}; private static int[] RewardGold = {}; private static ItemStack[] itemstack = {}; private static String[][] questDiscription = {new String[]{""}}; public QuestFarmer(int QuestNumber, int index) { super(QuestNumber, index, StartLines, EndLines, ProgressLines, QuestName, RewardXP, RewardGold, itemstack, questDiscription); } @Override
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // } // // Path: Journey of Legends/aginsun/journey/universal/utils/QuestType.java // public enum QuestType // { // GATHERING("Gathering"), // HUNTING("Hunting"), // STUFF("Stuff"); // // // private QuestType(String QuestType) // { // // } // } // Path: Journey of Legends/aginsun/journey/universal/quests/QuestFarmer.java import net.minecraft.item.ItemStack; import aginsun.journey.universal.utils.Quest; import aginsun.journey.universal.utils.QuestType; package aginsun.journey.universal.quests; public class QuestFarmer extends Quest { private static String[] StartLines = {""}; private static String[] EndLines = {}; private static String[] ProgressLines = {}; private static String[] QuestName = {}; private static int[] RewardXP = {}; private static int[] RewardGold = {}; private static ItemStack[] itemstack = {}; private static String[][] questDiscription = {new String[]{""}}; public QuestFarmer(int QuestNumber, int index) { super(QuestNumber, index, StartLines, EndLines, ProgressLines, QuestName, RewardXP, RewardGold, itemstack, questDiscription); } @Override
public QuestType getQuestType()
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/inventory/ContainerSell.java
// Path: Journey of Legends/aginsun/journey/universal/entities/TileEntitySell.java // public class TileEntitySell extends TileEntity implements IInventory // { // private ItemStack[] inventory; // public GoldKeeper gold; // public World world; // public EntityPlayer player; // public GoldValueHandler goldvalues; // public ExperienceKeeper experience; // public Player par1player; // // public TileEntitySell() // { // inventory = new ItemStack[1]; // } // // @Override // public int getSizeInventory() // { // return inventory.length; // } // // @Override // public ItemStack getStackInSlot(int i) // { // int j = 0; // if (inventory[i] != null) // { // for (int k = 0; k < inventory[i].stackSize; k++) // { // Item item = inventory[i].getItem(); // String s = item.getUnlocalizedName(); // j = goldvalues.getGoldValue(s); // if(FMLCommonHandler.instance().getEffectiveSide().isServer()) // gold.addGold(setPlayerName(player), j); // this.par1player = (Player)player; // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketGold(player.username, GoldKeeper.getGoldTotal(player))), (Player)player); // } // if (j != 0) // { // inventory[i] = null; // } // } // return inventory[i]; // } // @Override // public void setInventorySlotContents(int i, ItemStack itemstack) // { // inventory[i] = itemstack; // if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) // { // itemstack.stackSize = getInventoryStackLimit(); // } // } // @Override // public ItemStack decrStackSize(int i, int j) // { // if (inventory[i] != null) // { // if (inventory[i].stackSize <= j) // { // ItemStack itemstack = inventory[i]; // inventory[i] = null; // return itemstack; // } // ItemStack itemstack1 = inventory[i].splitStack(j); // if (inventory[i].stackSize == 0) // { // inventory[i] = null; // } // return itemstack1; // } // else // { // return null; // } // } // // @Override // public ItemStack getStackInSlotOnClosing(int slotIndex) // { // return null; // } // // @Override // public int getInventoryStackLimit() // { // return 64; // } // // @Override // public boolean isUseableByPlayer(EntityPlayer player) // { // return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; // } // // @Override // public void openChest() {} // // @Override // public void closeChest() {} // // @Override // public String getInvName() // { // return "TeSell"; // } // // public EntityPlayer setPlayerName(EntityPlayer player) // { // return this.player = player; // } // // @Override // public boolean isInvNameLocalized() { // return false; // } // // @Override // public boolean isItemValidForSlot(int i, ItemStack itemstack) // { // return false; // } // }
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import aginsun.journey.universal.entities.TileEntitySell;
package aginsun.journey.universal.inventory; public class ContainerSell extends Container {
// Path: Journey of Legends/aginsun/journey/universal/entities/TileEntitySell.java // public class TileEntitySell extends TileEntity implements IInventory // { // private ItemStack[] inventory; // public GoldKeeper gold; // public World world; // public EntityPlayer player; // public GoldValueHandler goldvalues; // public ExperienceKeeper experience; // public Player par1player; // // public TileEntitySell() // { // inventory = new ItemStack[1]; // } // // @Override // public int getSizeInventory() // { // return inventory.length; // } // // @Override // public ItemStack getStackInSlot(int i) // { // int j = 0; // if (inventory[i] != null) // { // for (int k = 0; k < inventory[i].stackSize; k++) // { // Item item = inventory[i].getItem(); // String s = item.getUnlocalizedName(); // j = goldvalues.getGoldValue(s); // if(FMLCommonHandler.instance().getEffectiveSide().isServer()) // gold.addGold(setPlayerName(player), j); // this.par1player = (Player)player; // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketGold(player.username, GoldKeeper.getGoldTotal(player))), (Player)player); // } // if (j != 0) // { // inventory[i] = null; // } // } // return inventory[i]; // } // @Override // public void setInventorySlotContents(int i, ItemStack itemstack) // { // inventory[i] = itemstack; // if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) // { // itemstack.stackSize = getInventoryStackLimit(); // } // } // @Override // public ItemStack decrStackSize(int i, int j) // { // if (inventory[i] != null) // { // if (inventory[i].stackSize <= j) // { // ItemStack itemstack = inventory[i]; // inventory[i] = null; // return itemstack; // } // ItemStack itemstack1 = inventory[i].splitStack(j); // if (inventory[i].stackSize == 0) // { // inventory[i] = null; // } // return itemstack1; // } // else // { // return null; // } // } // // @Override // public ItemStack getStackInSlotOnClosing(int slotIndex) // { // return null; // } // // @Override // public int getInventoryStackLimit() // { // return 64; // } // // @Override // public boolean isUseableByPlayer(EntityPlayer player) // { // return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; // } // // @Override // public void openChest() {} // // @Override // public void closeChest() {} // // @Override // public String getInvName() // { // return "TeSell"; // } // // public EntityPlayer setPlayerName(EntityPlayer player) // { // return this.player = player; // } // // @Override // public boolean isInvNameLocalized() { // return false; // } // // @Override // public boolean isItemValidForSlot(int i, ItemStack itemstack) // { // return false; // } // } // Path: Journey of Legends/aginsun/journey/universal/inventory/ContainerSell.java import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import aginsun.journey.universal.entities.TileEntitySell; package aginsun.journey.universal.inventory; public class ContainerSell extends Container {
protected TileEntitySell tile_entity;
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/server/api/StatKeeper.java
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketStatsClient.java // public class PacketStatsClient extends PacketJoL // { // private String username; // private int strength; // private int dexterity; // private int intelligence; // private int luck; // // public PacketStatsClient() // { // super(PacketType.STATS, false); // } // // public PacketStatsClient(String username, int strength, int dexterity, int intelligence, int luck) // { // super(PacketType.STATS, false); // this.username = username; // this.strength = strength; // this.dexterity = dexterity; // this.intelligence = intelligence; // this.luck = luck; // } // // @Override // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.strength = data.readInt(); // this.dexterity = data.readInt(); // this.intelligence = data.readInt(); // this.luck = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeInt(strength); // dos.writeInt(dexterity); // dos.writeInt(intelligence); // dos.writeInt(luck); // } // // public void execute(INetworkManager network, Player thePlayer) // { // EntityPlayer player = (EntityPlayer)thePlayer; // // StatKeeper.setStrengthPoints(player, strength); // StatKeeper.setDexerityPoints(player, dexterity); // StatKeeper.setIntelligencePoints(player, intelligence); // StatKeeper.setLuckPoints(player, luck); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // }
import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import aginsun.journey.universal.packets.PacketStatsClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player;
return 4; } else { return LuckMap.get(player.username); } } public static void setStrengthPoints(EntityPlayer player, int amount) { StrengthMap.put(player.username, amount); } public static void setDexerityPoints(EntityPlayer player, int amount) { DexeterityMap.put(player.username, amount); } public static void setIntelligencePoints(EntityPlayer player, int amount) { IntelligenceMap.put(player.username, amount); } public static void setLuckPoints(EntityPlayer player, int amount) { LuckMap.put(player.username, amount); } public static void addStrengthPoints(EntityPlayer player, int amount) { int i = getStrengthPoints(player); i += amount; setStrengthPoints(player, i);
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketStatsClient.java // public class PacketStatsClient extends PacketJoL // { // private String username; // private int strength; // private int dexterity; // private int intelligence; // private int luck; // // public PacketStatsClient() // { // super(PacketType.STATS, false); // } // // public PacketStatsClient(String username, int strength, int dexterity, int intelligence, int luck) // { // super(PacketType.STATS, false); // this.username = username; // this.strength = strength; // this.dexterity = dexterity; // this.intelligence = intelligence; // this.luck = luck; // } // // @Override // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.strength = data.readInt(); // this.dexterity = data.readInt(); // this.intelligence = data.readInt(); // this.luck = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeInt(strength); // dos.writeInt(dexterity); // dos.writeInt(intelligence); // dos.writeInt(luck); // } // // public void execute(INetworkManager network, Player thePlayer) // { // EntityPlayer player = (EntityPlayer)thePlayer; // // StatKeeper.setStrengthPoints(player, strength); // StatKeeper.setDexerityPoints(player, dexterity); // StatKeeper.setIntelligencePoints(player, intelligence); // StatKeeper.setLuckPoints(player, luck); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // } // Path: Journey of Legends/aginsun/journey/server/api/StatKeeper.java import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import aginsun.journey.universal.packets.PacketStatsClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; return 4; } else { return LuckMap.get(player.username); } } public static void setStrengthPoints(EntityPlayer player, int amount) { StrengthMap.put(player.username, amount); } public static void setDexerityPoints(EntityPlayer player, int amount) { DexeterityMap.put(player.username, amount); } public static void setIntelligencePoints(EntityPlayer player, int amount) { IntelligenceMap.put(player.username, amount); } public static void setLuckPoints(EntityPlayer player, int amount) { LuckMap.put(player.username, amount); } public static void addStrengthPoints(EntityPlayer player, int amount) { int i = getStrengthPoints(player); i += amount; setStrengthPoints(player, i);
PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/server/api/StatKeeper.java
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketStatsClient.java // public class PacketStatsClient extends PacketJoL // { // private String username; // private int strength; // private int dexterity; // private int intelligence; // private int luck; // // public PacketStatsClient() // { // super(PacketType.STATS, false); // } // // public PacketStatsClient(String username, int strength, int dexterity, int intelligence, int luck) // { // super(PacketType.STATS, false); // this.username = username; // this.strength = strength; // this.dexterity = dexterity; // this.intelligence = intelligence; // this.luck = luck; // } // // @Override // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.strength = data.readInt(); // this.dexterity = data.readInt(); // this.intelligence = data.readInt(); // this.luck = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeInt(strength); // dos.writeInt(dexterity); // dos.writeInt(intelligence); // dos.writeInt(luck); // } // // public void execute(INetworkManager network, Player thePlayer) // { // EntityPlayer player = (EntityPlayer)thePlayer; // // StatKeeper.setStrengthPoints(player, strength); // StatKeeper.setDexerityPoints(player, dexterity); // StatKeeper.setIntelligencePoints(player, intelligence); // StatKeeper.setLuckPoints(player, luck); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // }
import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import aginsun.journey.universal.packets.PacketStatsClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player;
return 4; } else { return LuckMap.get(player.username); } } public static void setStrengthPoints(EntityPlayer player, int amount) { StrengthMap.put(player.username, amount); } public static void setDexerityPoints(EntityPlayer player, int amount) { DexeterityMap.put(player.username, amount); } public static void setIntelligencePoints(EntityPlayer player, int amount) { IntelligenceMap.put(player.username, amount); } public static void setLuckPoints(EntityPlayer player, int amount) { LuckMap.put(player.username, amount); } public static void addStrengthPoints(EntityPlayer player, int amount) { int i = getStrengthPoints(player); i += amount; setStrengthPoints(player, i);
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketStatsClient.java // public class PacketStatsClient extends PacketJoL // { // private String username; // private int strength; // private int dexterity; // private int intelligence; // private int luck; // // public PacketStatsClient() // { // super(PacketType.STATS, false); // } // // public PacketStatsClient(String username, int strength, int dexterity, int intelligence, int luck) // { // super(PacketType.STATS, false); // this.username = username; // this.strength = strength; // this.dexterity = dexterity; // this.intelligence = intelligence; // this.luck = luck; // } // // @Override // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.strength = data.readInt(); // this.dexterity = data.readInt(); // this.intelligence = data.readInt(); // this.luck = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeInt(strength); // dos.writeInt(dexterity); // dos.writeInt(intelligence); // dos.writeInt(luck); // } // // public void execute(INetworkManager network, Player thePlayer) // { // EntityPlayer player = (EntityPlayer)thePlayer; // // StatKeeper.setStrengthPoints(player, strength); // StatKeeper.setDexerityPoints(player, dexterity); // StatKeeper.setIntelligencePoints(player, intelligence); // StatKeeper.setLuckPoints(player, luck); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // } // Path: Journey of Legends/aginsun/journey/server/api/StatKeeper.java import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import aginsun.journey.universal.packets.PacketStatsClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; return 4; } else { return LuckMap.get(player.username); } } public static void setStrengthPoints(EntityPlayer player, int amount) { StrengthMap.put(player.username, amount); } public static void setDexerityPoints(EntityPlayer player, int amount) { DexeterityMap.put(player.username, amount); } public static void setIntelligencePoints(EntityPlayer player, int amount) { IntelligenceMap.put(player.username, amount); } public static void setLuckPoints(EntityPlayer player, int amount) { LuckMap.put(player.username, amount); } public static void addStrengthPoints(EntityPlayer player, int amount) { int i = getStrengthPoints(player); i += amount; setStrengthPoints(player, i);
PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/worldgen/WorldgenChests.java
// Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // }
import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; import aginsun.journey.universal.items.InitItems;
package aginsun.journey.universal.worldgen; public class WorldgenChests { public static void Init() {
// Path: Journey of Legends/aginsun/journey/universal/items/InitItems.java // public class InitItems // { // public static String ModID = Utils.modID; // // public static Item ItemCoins; // public static int ItemCoinsID; // // public static Item ItemExcalibur; // public static int ItemExcaliburID; // // public static Item ItemAgBlade; // public static int ItemAgBladeID; // // public static Item ItemExcaliburMace; // public static int ItemExcaliburMaceID; // // public static Item ItemDebug; // public static int ItemDebugID; // // public static Item itemShuricken; // public static int itemShurickenID; // // public static Item itemRedClaw; // public static int itemRedClawID; // // public static void Init() // { // ItemCoins = new ItemCoins(ItemCoinsID).setUnlocalizedName("Coins").func_111206_d(ModID + ":coins"); // ItemExcalibur = new ItemExcaliburSword(ItemExcaliburID).setUnlocalizedName("Excalibur").func_111206_d(ModID+":"+"Sword15"); // ItemAgBlade = new ItemAgBlade(ItemAgBladeID).setUnlocalizedName("AgBlade").func_111206_d(ModID+":"+"AginsunsBlade"); // ItemExcaliburMace = new ItemExcaliburMace(ItemExcaliburMaceID).setUnlocalizedName("ExMace").func_111206_d(ModID+":"+"ExcaliburMace"); // ItemDebug = new ItemDebug(ItemDebugID).setUnlocalizedName("Debug").func_111206_d(ModID+":"+"DebugToK"); // itemRedClaw = new ItemRedClaw(itemRedClawID).setUnlocalizedName("RedClaw").func_111206_d(ModID+":redClaw"); // itemShuricken = new ItemShuricken(itemShurickenID).setUnlocalizedName("shurickenStar").func_111206_d(ModID+":shurickenStar"); // languageRegisterers(); // } // // public static void languageRegisterers() // { // LanguageRegistry.addName(ItemCoins, "Coins"); // LanguageRegistry.addName(ItemExcalibur, "Excalibur"); // LanguageRegistry.addName(ItemAgBlade, "Aginsuns Blade"); // LanguageRegistry.addName(ItemExcaliburMace, "Excalibur Mace"); // LanguageRegistry.addName(ItemDebug, "Debug Tool ToK2"); // LanguageRegistry.addName(itemRedClaw, "Red Claw"); // LanguageRegistry.addName(itemShuricken, "Shuricken Star"); // } // } // Path: Journey of Legends/aginsun/journey/universal/worldgen/WorldgenChests.java import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; import aginsun.journey.universal.items.InitItems; package aginsun.journey.universal.worldgen; public class WorldgenChests { public static void Init() {
WeightedRandomChestContent x = new WeightedRandomChestContent(new ItemStack(InitItems.ItemExcalibur), 50, 95, 4);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/quests/QuestGuildMaster.java
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // } // // Path: Journey of Legends/aginsun/journey/universal/utils/QuestType.java // public enum QuestType // { // GATHERING("Gathering"), // HUNTING("Hunting"), // STUFF("Stuff"); // // // private QuestType(String QuestType) // { // // } // }
import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import aginsun.journey.universal.utils.Quest; import aginsun.journey.universal.utils.QuestType;
package aginsun.journey.universal.quests; public class QuestGuildMaster extends Quest { private static String[] StartLines = {"Open the Stat Screen by pressing O on your keyboard.", "Go and level up!", "Go and kill 10 zombies!", "Go and reach level 10!"}; private static String[] EndLines = {"Very well, now you are aware where you can upgrade your statpoints!", "Very well, now go and spend your stat points!-" + "Try and decide your choice by what you want to choose, Strength for warrior, Dexerity for hunter, Intelligence for wizard and luck for thief.", "Thank you for killing them, now my house will not be threathned for a while", null}; private static String[] ProgressLines = {"Go on, press O on your keyboard", "Go and level, you are not there yet!", "Go on, kill those pesky zombies", "You are on your way to level 10, but you are not yet there."}; private static String[] QuestName = {"The beginning of a great adventure", "Leveling", "Hunting", "Progression"}; private static int[] RewardXP = {100, 50, 50, 150}; private static int[] RewardGold = {10, 50, 50, 100}; private static ItemStack[] itemstack = {null, null, null, new ItemStack(Item.arrow)};
// Path: Journey of Legends/aginsun/journey/universal/utils/Quest.java // public abstract class Quest // { // private EntityPlayer player; // // private int QuestNumber; // private int index; // private String[] StartLines; // private String[] EndLines; // private String[] ProgressLines; // private String[] QuestName; // private int[] RewardXP; // private int[] RewardGold; // private ItemStack[] itemstack; // private String[][] questDiscription; // // public Quest(int QuestNumber) // { // this.QuestNumber = QuestNumber; // } // // public Quest(int QuestNumber, int index, String[] StartLines, String[] EndLines, String[] ProgressLines, String[] QuestName, int[] RewardXP, int[] RewardGold, ItemStack[] itemstack, String[][] questDiscription) // { // this(QuestNumber); // this.index = index; // this.StartLines = StartLines; // this.EndLines = EndLines; // this.ProgressLines = ProgressLines; // this.QuestName = QuestName; // this.RewardXP = RewardXP; // this.RewardGold = RewardGold; // this.itemstack = itemstack; // this.questDiscription = questDiscription; // } // // public void update() // { // int QuestStatus = QuestHandler.instance().getQuestStatusClient(player, getQuestName()); // System.out.println("QuestStatus: " + QuestStatus); // QuestType questtype = getQuestType(); // // if(QuestStatus == 0 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, false)); // return; // } // if(QuestStatus == 0 && questtype == QuestType.GATHERING) // { // return; // } // if(QuestStatus == 1) // { // player.addChatMessage(this.questProgressLine(player)); // return; // } // if(QuestStatus == 2 && (questtype == QuestType.HUNTING || questtype == QuestType.STUFF)) // { // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(getQuestName(), this, true)); // return; // } // else // { // player.addChatMessage(this.standardLine()); // return; // } // } // // // public Quest setPlayer(EntityPlayer player) // { // this.player = player; // return this; // } // // private String standardLine() // { // return "I currently do not have any quests for you."; // } // // public void questEndReward(EntityPlayer player) // { // GoldKeeper.addGold(player, questEndRewardGold(player)); // ExperienceKeeper.addExperience(player, questEndRewardXP(player)); // if(questEndRewardItemStacks(player) != null) // { // player.dropItem(questEndRewardItemStacks(player).itemID, questEndRewardItemStacks(player).stackSize); // } // } // // public String questStartLines(EntityPlayer player) // { // return StartLines[index]; // } // // public String questEndLines(EntityPlayer player) // { // return EndLines[index]; // } // // public String questProgressLine(EntityPlayer player) // { // return ProgressLines[index]; // } // // public int questEndRewardXP(EntityPlayer player) // { // return RewardXP[index]; // } // // public int questEndRewardGold(EntityPlayer player) // { // return RewardGold[index]; // } // // public ItemStack questEndRewardItemStacks(EntityPlayer player) // { // return itemstack[index]; // } // // public String getQuestName() // { // return QuestName[index]; // } // // public String[] getQuestDiscription() // { // return questDiscription[index]; // } // // public int getQuestNumber() // { // return QuestNumber; // } // // public abstract QuestType getQuestType(); // } // // Path: Journey of Legends/aginsun/journey/universal/utils/QuestType.java // public enum QuestType // { // GATHERING("Gathering"), // HUNTING("Hunting"), // STUFF("Stuff"); // // // private QuestType(String QuestType) // { // // } // } // Path: Journey of Legends/aginsun/journey/universal/quests/QuestGuildMaster.java import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import aginsun.journey.universal.utils.Quest; import aginsun.journey.universal.utils.QuestType; package aginsun.journey.universal.quests; public class QuestGuildMaster extends Quest { private static String[] StartLines = {"Open the Stat Screen by pressing O on your keyboard.", "Go and level up!", "Go and kill 10 zombies!", "Go and reach level 10!"}; private static String[] EndLines = {"Very well, now you are aware where you can upgrade your statpoints!", "Very well, now go and spend your stat points!-" + "Try and decide your choice by what you want to choose, Strength for warrior, Dexerity for hunter, Intelligence for wizard and luck for thief.", "Thank you for killing them, now my house will not be threathned for a while", null}; private static String[] ProgressLines = {"Go on, press O on your keyboard", "Go and level, you are not there yet!", "Go on, kill those pesky zombies", "You are on your way to level 10, but you are not yet there."}; private static String[] QuestName = {"The beginning of a great adventure", "Leveling", "Hunting", "Progression"}; private static int[] RewardXP = {100, 50, 50, 150}; private static int[] RewardGold = {10, 50, 50, 100}; private static ItemStack[] itemstack = {null, null, null, new ItemStack(Item.arrow)};
private static QuestType[] questType = {QuestType.STUFF, QuestType.STUFF, QuestType.HUNTING, QuestType.STUFF};
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/client/handlers/KeyBindingHandler.java
// Path: Journey of Legends/aginsun/journey/client/guis/GuiStats.java // public class GuiStats extends GuiScreen // { // private StatKeeper stats; // private EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; // private LevelKeeper level; // // public void initGui() // { // buttonList.clear(); // // if(level.getSP(player) > 0) // { // buttonList.add(new GuiButton(1, width / 2 - 20, 15, 120, 20, "Upgrade Strength")); // buttonList.add(new GuiButton(2, width / 2 - 20, 75, 120, 20, "Upgrade Dexerity")); // buttonList.add(new GuiButton(3, width / 2 - 20, 135, 120, 20, "Upgrade Intelligence")); // buttonList.add(new GuiButton(4, width / 2 - 20, 195, 120, 20, "Upgrade Luck")); // } // } // // public void actionPerformed(GuiButton guibutton) // { // if(guibutton.id == 1) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "STR", 1))); // initGui(); // } // if(guibutton.id == 2) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "DEX", 1))); // initGui(); // } // if(guibutton.id == 3) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "INT", 1))); // initGui(); // } // if(guibutton.id == 4) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "LUK", 1))); // initGui(); // } // } // // public boolean doesGuiPauseGame() // { // return false; // } // // public void onGuiClosed() // { // if(QuestHandler.instance().getQuestStatusClient(player, "The beginning of a great adventure") == 1) // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketQuestData(player.username, "The beginning of a great adventure", 2))); // } // // // public void drawScreen(int i, int j, float f) // { // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); // char c = '\377'; // char c1 = '\377'; // ResourceLocation resource = new ResourceLocation("journeyoflegends", "textures/guis/crafting.png"); // mc.renderEngine.func_110577_a(resource); // int i1 = (width - c) / 2; // drawTexturedModalRect(i1, 0, 0, 0, c, c1); // drawString(fontRenderer, new StringBuilder("Strength: ").append(stats.getStrengthPoints(player)).toString(), width / 2 - 100, 20, 0xffcc00); // drawString(fontRenderer, new StringBuilder("Dexerity: ").append(stats.getDexerityPoints(player)).toString(), width / 2 - 100, 80, 0xffcc00); // drawString(fontRenderer, new StringBuilder("Intelligence: ").append(stats.getIntelligencePoints(player)).toString(), width / 2 - 100, 140, 0xffcc00); // drawString(fontRenderer, new StringBuilder("Luck: ").append(stats.getLuckPoints(player)).toString(), width / 2 - 100, 200, 0xffcc00); // for (int m = 0; m < buttonList.size(); m++) // { // GuiButton guibutton = (GuiButton)buttonList.get(m); // guibutton.drawButton(mc, i, j); // } // super.drawScreen(i, j, f); // } // }
import java.util.EnumSet; import net.minecraft.client.settings.KeyBinding; import org.lwjgl.input.Keyboard; import aginsun.journey.client.guis.GuiStats; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.TickType;
package aginsun.journey.client.handlers; public class KeyBindingHandler extends KeyHandler { public static KeyBinding StatsScreen = new KeyBinding("Tale of Kingdoms 2 StatScreen", Keyboard.KEY_O); public static KeyBinding[] arrayOfKeys = new KeyBinding[] {StatsScreen}; public static boolean[] areRepeating = new boolean[] {false}; public KeyBindingHandler() { super(arrayOfKeys, areRepeating); } @Override public String getLabel() { return "Tale of Kingdoms 2 Keybindings"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if (FMLClientHandler.instance().getClient().currentScreen == null) { if(kb.keyCode == StatsScreen.keyCode) {
// Path: Journey of Legends/aginsun/journey/client/guis/GuiStats.java // public class GuiStats extends GuiScreen // { // private StatKeeper stats; // private EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; // private LevelKeeper level; // // public void initGui() // { // buttonList.clear(); // // if(level.getSP(player) > 0) // { // buttonList.add(new GuiButton(1, width / 2 - 20, 15, 120, 20, "Upgrade Strength")); // buttonList.add(new GuiButton(2, width / 2 - 20, 75, 120, 20, "Upgrade Dexerity")); // buttonList.add(new GuiButton(3, width / 2 - 20, 135, 120, 20, "Upgrade Intelligence")); // buttonList.add(new GuiButton(4, width / 2 - 20, 195, 120, 20, "Upgrade Luck")); // } // } // // public void actionPerformed(GuiButton guibutton) // { // if(guibutton.id == 1) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "STR", 1))); // initGui(); // } // if(guibutton.id == 2) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "DEX", 1))); // initGui(); // } // if(guibutton.id == 3) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "INT", 1))); // initGui(); // } // if(guibutton.id == 4) // { // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketStatChange(player.username, "LUK", 1))); // initGui(); // } // } // // public boolean doesGuiPauseGame() // { // return false; // } // // public void onGuiClosed() // { // if(QuestHandler.instance().getQuestStatusClient(player, "The beginning of a great adventure") == 1) // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketQuestData(player.username, "The beginning of a great adventure", 2))); // } // // // public void drawScreen(int i, int j, float f) // { // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); // char c = '\377'; // char c1 = '\377'; // ResourceLocation resource = new ResourceLocation("journeyoflegends", "textures/guis/crafting.png"); // mc.renderEngine.func_110577_a(resource); // int i1 = (width - c) / 2; // drawTexturedModalRect(i1, 0, 0, 0, c, c1); // drawString(fontRenderer, new StringBuilder("Strength: ").append(stats.getStrengthPoints(player)).toString(), width / 2 - 100, 20, 0xffcc00); // drawString(fontRenderer, new StringBuilder("Dexerity: ").append(stats.getDexerityPoints(player)).toString(), width / 2 - 100, 80, 0xffcc00); // drawString(fontRenderer, new StringBuilder("Intelligence: ").append(stats.getIntelligencePoints(player)).toString(), width / 2 - 100, 140, 0xffcc00); // drawString(fontRenderer, new StringBuilder("Luck: ").append(stats.getLuckPoints(player)).toString(), width / 2 - 100, 200, 0xffcc00); // for (int m = 0; m < buttonList.size(); m++) // { // GuiButton guibutton = (GuiButton)buttonList.get(m); // guibutton.drawButton(mc, i, j); // } // super.drawScreen(i, j, f); // } // } // Path: Journey of Legends/aginsun/journey/client/handlers/KeyBindingHandler.java import java.util.EnumSet; import net.minecraft.client.settings.KeyBinding; import org.lwjgl.input.Keyboard; import aginsun.journey.client.guis.GuiStats; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.TickType; package aginsun.journey.client.handlers; public class KeyBindingHandler extends KeyHandler { public static KeyBinding StatsScreen = new KeyBinding("Tale of Kingdoms 2 StatScreen", Keyboard.KEY_O); public static KeyBinding[] arrayOfKeys = new KeyBinding[] {StatsScreen}; public static boolean[] areRepeating = new boolean[] {false}; public KeyBindingHandler() { super(arrayOfKeys, areRepeating); } @Override public String getLabel() { return "Tale of Kingdoms 2 Keybindings"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if (FMLClientHandler.instance().getClient().currentScreen == null) { if(kb.keyCode == StatsScreen.keyCode) {
FMLCommonHandler.instance().showGuiScreen(new GuiStats());
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketStatsClient.java
// Path: Journey of Legends/aginsun/journey/server/api/StatKeeper.java // public class StatKeeper // { // public static HashMap<String, Integer> StrengthMap = new HashMap<String, Integer>(); // public static HashMap<String, Integer> DexeterityMap = new HashMap<String, Integer>(); // public static HashMap<String, Integer> IntelligenceMap = new HashMap<String, Integer>(); // public static HashMap<String, Integer> LuckMap = new HashMap<String, Integer>(); // // public static int getStrengthPoints(EntityPlayer player) // { // if(!StrengthMap.containsKey(player.username)) // { // return 4; // } // else if(StrengthMap.get(player.username) == 0) // { // return 4; // } // else // { // return StrengthMap.get(player.username); // } // } // public static int getDexerityPoints(EntityPlayer player) // { // if(!DexeterityMap.containsKey(player.username)) // { // return 4; // } // else if (DexeterityMap.get(player.username) == 0) // { // return 4; // } // else // { // return DexeterityMap.get(player.username); // } // } // public static int getIntelligencePoints(EntityPlayer player) // { // if(!IntelligenceMap.containsKey(player.username)) // { // return 4; // } // else if(IntelligenceMap.get(player.username) == 0) // { // return 4; // } // else // { // return IntelligenceMap.get(player.username); // } // } // public static int getLuckPoints(EntityPlayer player) // { // if(!LuckMap.containsKey(player.username)) // { // return 4; // } // else if(LuckMap.get(player.username) == 0) // { // return 4; // } // else // { // return LuckMap.get(player.username); // } // } // // public static void setStrengthPoints(EntityPlayer player, int amount) // { // StrengthMap.put(player.username, amount); // } // public static void setDexerityPoints(EntityPlayer player, int amount) // { // DexeterityMap.put(player.username, amount); // } // public static void setIntelligencePoints(EntityPlayer player, int amount) // { // IntelligenceMap.put(player.username, amount); // } // public static void setLuckPoints(EntityPlayer player, int amount) // { // LuckMap.put(player.username, amount); // } // // public static void addStrengthPoints(EntityPlayer player, int amount) // { // int i = getStrengthPoints(player); // i += amount; // setStrengthPoints(player, i); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // public static void addDexPoints(EntityPlayer player, int amount) // { // int j = getDexerityPoints(player); // j += amount; // setDexerityPoints(player, j); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // public static void addIntPoints(EntityPlayer player, int amount) // { // int j = getIntelligencePoints(player); // j += amount; // setIntelligencePoints(player, j); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // public static void addLukPoints(EntityPlayer player, int amount) // { // int j = getLuckPoints(player); // j += amount; // setLuckPoints(player, j); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.StatKeeper; import cpw.mods.fml.common.network.Player;
this.username = username; this.strength = strength; this.dexterity = dexterity; this.intelligence = intelligence; this.luck = luck; } @Override public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.strength = data.readInt(); this.dexterity = data.readInt(); this.intelligence = data.readInt(); this.luck = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(strength); dos.writeInt(dexterity); dos.writeInt(intelligence); dos.writeInt(luck); } public void execute(INetworkManager network, Player thePlayer) { EntityPlayer player = (EntityPlayer)thePlayer;
// Path: Journey of Legends/aginsun/journey/server/api/StatKeeper.java // public class StatKeeper // { // public static HashMap<String, Integer> StrengthMap = new HashMap<String, Integer>(); // public static HashMap<String, Integer> DexeterityMap = new HashMap<String, Integer>(); // public static HashMap<String, Integer> IntelligenceMap = new HashMap<String, Integer>(); // public static HashMap<String, Integer> LuckMap = new HashMap<String, Integer>(); // // public static int getStrengthPoints(EntityPlayer player) // { // if(!StrengthMap.containsKey(player.username)) // { // return 4; // } // else if(StrengthMap.get(player.username) == 0) // { // return 4; // } // else // { // return StrengthMap.get(player.username); // } // } // public static int getDexerityPoints(EntityPlayer player) // { // if(!DexeterityMap.containsKey(player.username)) // { // return 4; // } // else if (DexeterityMap.get(player.username) == 0) // { // return 4; // } // else // { // return DexeterityMap.get(player.username); // } // } // public static int getIntelligencePoints(EntityPlayer player) // { // if(!IntelligenceMap.containsKey(player.username)) // { // return 4; // } // else if(IntelligenceMap.get(player.username) == 0) // { // return 4; // } // else // { // return IntelligenceMap.get(player.username); // } // } // public static int getLuckPoints(EntityPlayer player) // { // if(!LuckMap.containsKey(player.username)) // { // return 4; // } // else if(LuckMap.get(player.username) == 0) // { // return 4; // } // else // { // return LuckMap.get(player.username); // } // } // // public static void setStrengthPoints(EntityPlayer player, int amount) // { // StrengthMap.put(player.username, amount); // } // public static void setDexerityPoints(EntityPlayer player, int amount) // { // DexeterityMap.put(player.username, amount); // } // public static void setIntelligencePoints(EntityPlayer player, int amount) // { // IntelligenceMap.put(player.username, amount); // } // public static void setLuckPoints(EntityPlayer player, int amount) // { // LuckMap.put(player.username, amount); // } // // public static void addStrengthPoints(EntityPlayer player, int amount) // { // int i = getStrengthPoints(player); // i += amount; // setStrengthPoints(player, i); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // public static void addDexPoints(EntityPlayer player, int amount) // { // int j = getDexerityPoints(player); // j += amount; // setDexerityPoints(player, j); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // public static void addIntPoints(EntityPlayer player, int amount) // { // int j = getIntelligencePoints(player); // j += amount; // setIntelligencePoints(player, j); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // public static void addLukPoints(EntityPlayer player, int amount) // { // int j = getLuckPoints(player); // j += amount; // setLuckPoints(player, j); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketStatsClient(player.username, StatKeeper.getStrengthPoints(player), StatKeeper.getDexerityPoints(player), StatKeeper.getIntelligencePoints(player), StatKeeper.getLuckPoints(player))), (Player)player); // } // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketStatsClient.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.StatKeeper; import cpw.mods.fml.common.network.Player; this.username = username; this.strength = strength; this.dexterity = dexterity; this.intelligence = intelligence; this.luck = luck; } @Override public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.strength = data.readInt(); this.dexterity = data.readInt(); this.intelligence = data.readInt(); this.luck = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(strength); dos.writeInt(dexterity); dos.writeInt(intelligence); dos.writeInt(luck); } public void execute(INetworkManager network, Player thePlayer) { EntityPlayer player = (EntityPlayer)thePlayer;
StatKeeper.setStrengthPoints(player, strength);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/server/api/QuestHandler.java
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketQuestDataClient.java // public class PacketQuestDataClient extends PacketJoL // { // private String username; // private String questName; // private int questStatus; // // public PacketQuestDataClient() // { // super(PacketType.QUESTDATACLIENT, false); // } // // public PacketQuestDataClient(String username, String questName, int questStatus) // { // super(PacketType.QUESTDATACLIENT, false); // this.username = username; // this.questName = questName; // this.questStatus = questStatus; // } // // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.questName = data.readUTF(); // this.questStatus = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeUTF(questName); // dos.writeInt(questStatus); // } // // public void execute(INetworkManager network, Player player) // { // EntityPlayer thePlayer = (EntityPlayer)player; // // QuestHandler.instance().setQuestStatusClient(thePlayer, questName, questStatus); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // }
import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import aginsun.journey.universal.packets.PacketQuestDataClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package aginsun.journey.server.api; /** * WIP: QuestHandler: 1 == QuestStarted, 2 == QuestFinished, 3 == QuestFinished + reward! * @author Aginsun */ public class QuestHandler { private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); private static QuestHandler instance = new QuestHandler(); public QuestHandler(){} public static QuestHandler instance() { return instance; } public int getQuestStatus(EntityPlayer player, String QuestName) { NBTTagCompound nbt = getQuestPlayer(player); return nbt.getInteger(QuestName); } public void setQuestStatus(EntityPlayer player, String questName, int questStatus) { NBTTagCompound nbt = getQuestPlayer(player); nbt.setInteger(questName, questStatus);
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketQuestDataClient.java // public class PacketQuestDataClient extends PacketJoL // { // private String username; // private String questName; // private int questStatus; // // public PacketQuestDataClient() // { // super(PacketType.QUESTDATACLIENT, false); // } // // public PacketQuestDataClient(String username, String questName, int questStatus) // { // super(PacketType.QUESTDATACLIENT, false); // this.username = username; // this.questName = questName; // this.questStatus = questStatus; // } // // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.questName = data.readUTF(); // this.questStatus = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeUTF(questName); // dos.writeInt(questStatus); // } // // public void execute(INetworkManager network, Player player) // { // EntityPlayer thePlayer = (EntityPlayer)player; // // QuestHandler.instance().setQuestStatusClient(thePlayer, questName, questStatus); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // } // Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import aginsun.journey.universal.packets.PacketQuestDataClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package aginsun.journey.server.api; /** * WIP: QuestHandler: 1 == QuestStarted, 2 == QuestFinished, 3 == QuestFinished + reward! * @author Aginsun */ public class QuestHandler { private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); private static QuestHandler instance = new QuestHandler(); public QuestHandler(){} public static QuestHandler instance() { return instance; } public int getQuestStatus(EntityPlayer player, String QuestName) { NBTTagCompound nbt = getQuestPlayer(player); return nbt.getInteger(QuestName); } public void setQuestStatus(EntityPlayer player, String questName, int questStatus) { NBTTagCompound nbt = getQuestPlayer(player); nbt.setInteger(questName, questStatus);
PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/server/api/QuestHandler.java
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketQuestDataClient.java // public class PacketQuestDataClient extends PacketJoL // { // private String username; // private String questName; // private int questStatus; // // public PacketQuestDataClient() // { // super(PacketType.QUESTDATACLIENT, false); // } // // public PacketQuestDataClient(String username, String questName, int questStatus) // { // super(PacketType.QUESTDATACLIENT, false); // this.username = username; // this.questName = questName; // this.questStatus = questStatus; // } // // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.questName = data.readUTF(); // this.questStatus = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeUTF(questName); // dos.writeInt(questStatus); // } // // public void execute(INetworkManager network, Player player) // { // EntityPlayer thePlayer = (EntityPlayer)player; // // QuestHandler.instance().setQuestStatusClient(thePlayer, questName, questStatus); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // }
import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import aginsun.journey.universal.packets.PacketQuestDataClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package aginsun.journey.server.api; /** * WIP: QuestHandler: 1 == QuestStarted, 2 == QuestFinished, 3 == QuestFinished + reward! * @author Aginsun */ public class QuestHandler { private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); private static QuestHandler instance = new QuestHandler(); public QuestHandler(){} public static QuestHandler instance() { return instance; } public int getQuestStatus(EntityPlayer player, String QuestName) { NBTTagCompound nbt = getQuestPlayer(player); return nbt.getInteger(QuestName); } public void setQuestStatus(EntityPlayer player, String questName, int questStatus) { NBTTagCompound nbt = getQuestPlayer(player); nbt.setInteger(questName, questStatus);
// Path: Journey of Legends/aginsun/journey/universal/packets/PacketQuestDataClient.java // public class PacketQuestDataClient extends PacketJoL // { // private String username; // private String questName; // private int questStatus; // // public PacketQuestDataClient() // { // super(PacketType.QUESTDATACLIENT, false); // } // // public PacketQuestDataClient(String username, String questName, int questStatus) // { // super(PacketType.QUESTDATACLIENT, false); // this.username = username; // this.questName = questName; // this.questStatus = questStatus; // } // // public void readData(DataInputStream data) throws IOException // { // this.username = data.readUTF(); // this.questName = data.readUTF(); // this.questStatus = data.readInt(); // } // // public void writeData(DataOutputStream dos) throws IOException // { // dos.writeUTF(username); // dos.writeUTF(questName); // dos.writeInt(questStatus); // } // // public void execute(INetworkManager network, Player player) // { // EntityPlayer thePlayer = (EntityPlayer)player; // // QuestHandler.instance().setQuestStatusClient(thePlayer, questName, questStatus); // } // } // // Path: Journey of Legends/aginsun/journey/universal/packets/PacketType.java // public enum PacketType // { // GOLD(PacketGold.class), // EXPERIENCE(PacketExperience.class), // STATS(PacketStatsClient.class), // STATCHANGE(PacketStatChange.class), // RACE(PacketRace.class), // QUESTDATA(PacketQuestData.class), // QUESTDATACLIENT(PacketQuestDataClient.class), // LEVEL(PacketLevel.class), // SOUND(PacketSound.class); // // private Class<? extends PacketJoL> clazz; // // PacketType(Class<? extends PacketJoL> clazz) // { // this.clazz = clazz; // } // // public static PacketJoL buildPacket(byte[] data) { // // ByteArrayInputStream bis = new ByteArrayInputStream(data); // int selector = bis.read(); // DataInputStream dis = new DataInputStream(bis); // // PacketJoL packet = null; // // try { // packet = values()[selector].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // packet.readPopulate(dis); // // return packet; // } // // public static PacketJoL buildPacket(PacketType type) { // // PacketJoL packet = null; // // try { // packet = values()[type.ordinal()].clazz.newInstance(); // } // catch (Exception e) { // e.printStackTrace(System.err); // } // // return packet; // } // // public static Packet populatePacket(PacketJoL packetToK) { // // byte[] data = packetToK.populate(); // // Packet250CustomPayload packet250 = new Packet250CustomPayload(); // packet250.channel = Utils.modID; // packet250.data = data; // packet250.length = data.length; // packet250.isChunkDataPacket = packetToK.isChunkDataPacket; // // return packet250; // } // } // Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import aginsun.journey.universal.packets.PacketQuestDataClient; import aginsun.journey.universal.packets.PacketType; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package aginsun.journey.server.api; /** * WIP: QuestHandler: 1 == QuestStarted, 2 == QuestFinished, 3 == QuestFinished + reward! * @author Aginsun */ public class QuestHandler { private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); private static QuestHandler instance = new QuestHandler(); public QuestHandler(){} public static QuestHandler instance() { return instance; } public int getQuestStatus(EntityPlayer player, String QuestName) { NBTTagCompound nbt = getQuestPlayer(player); return nbt.getInteger(QuestName); } public void setQuestStatus(EntityPlayer player, String questName, int questStatus) { NBTTagCompound nbt = getQuestPlayer(player); nbt.setInteger(questName, questStatus);
PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/handlers/LivingDeathEventHandler.java
// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java // public class QuestHandler // { // private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); // private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); // private static QuestHandler instance = new QuestHandler(); // // public QuestHandler(){} // // public static QuestHandler instance() // { // return instance; // } // // public int getQuestStatus(EntityPlayer player, String QuestName) // { // NBTTagCompound nbt = getQuestPlayer(player); // return nbt.getInteger(QuestName); // } // // public void setQuestStatus(EntityPlayer player, String questName, int questStatus) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(questName, questStatus); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestStarted(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 1); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestFinished(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 2); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void questFinishedReward(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 3); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt) // { // System.out.println("Added player: " + player.username + " to the QuestMap"); // getMap().put(player.username, nbt); // } // // public boolean isQuestActive(EntityPlayer player, String questName) // { // if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0) // return true; // return false; // } // // public NBTTagCompound getQuestPlayer(EntityPlayer player) // { // if(getMap().containsKey(player.username)) // { // System.out.println("Does have the player in there"); // return getMap().get(player.username); // } // return null; // } // // public HashMap<String, NBTTagCompound> getMap() // { // return questList; // } // // @SideOnly(Side.CLIENT) // public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) // { // HashMap<String, Integer> map = questProgress.get(player.username); // if(map == null) // map = new HashMap<String, Integer>(); // map.put(questName, questStatus); // questProgress.put(player.username, map); // } // // @SideOnly(Side.CLIENT) // public int getQuestStatusClient(EntityPlayer player, String questName) // { // HashMap<String, Integer> map; // if(questProgress.containsKey(player.username)) // { // map = questProgress.get(player.username); // } // else // map = new HashMap<String, Integer>(); // // if(map.containsKey(questName)) // return map.get(questName); // return 0; // } // // @SideOnly(Side.CLIENT) // public boolean isQuestActiveClient(EntityPlayer player, String questName) // { // if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0) // return true; // return false; // } // }
import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDeathEvent; import aginsun.journey.server.api.QuestHandler;
package aginsun.journey.universal.handlers; public class LivingDeathEventHandler { @ForgeSubscribe public void onLivingDeath(LivingDeathEvent event) { if(event.source.getDamageType().equals("player")){ EntityPlayer player = (EntityPlayer)event.source.getSourceOfDamage(); if(event.entityLiving instanceof EntityZombie){
// Path: Journey of Legends/aginsun/journey/server/api/QuestHandler.java // public class QuestHandler // { // private HashMap<String, NBTTagCompound> questList = new HashMap<String, NBTTagCompound>(); // private HashMap<String, HashMap<String, Integer>> questProgress = new HashMap<String, HashMap<String, Integer>>(); // private static QuestHandler instance = new QuestHandler(); // // public QuestHandler(){} // // public static QuestHandler instance() // { // return instance; // } // // public int getQuestStatus(EntityPlayer player, String QuestName) // { // NBTTagCompound nbt = getQuestPlayer(player); // return nbt.getInteger(QuestName); // } // // public void setQuestStatus(EntityPlayer player, String questName, int questStatus) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(questName, questStatus); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, questName, questStatus)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestStarted(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 1); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 1)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestFinished(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 2); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 2)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void questFinishedReward(EntityPlayer player, String quest) // { // NBTTagCompound nbt = getQuestPlayer(player); // nbt.setInteger(quest, 3); // PacketDispatcher.sendPacketToPlayer(PacketType.populatePacket(new PacketQuestDataClient(player.username, quest, 3)), (Player)player); // setQuestPlayer(player, nbt); // } // // public void setQuestPlayer(EntityPlayer player, NBTTagCompound nbt) // { // System.out.println("Added player: " + player.username + " to the QuestMap"); // getMap().put(player.username, nbt); // } // // public boolean isQuestActive(EntityPlayer player, String questName) // { // if(getQuestStatus(player, questName) != 3 && getQuestStatus(player, questName) != 0) // return true; // return false; // } // // public NBTTagCompound getQuestPlayer(EntityPlayer player) // { // if(getMap().containsKey(player.username)) // { // System.out.println("Does have the player in there"); // return getMap().get(player.username); // } // return null; // } // // public HashMap<String, NBTTagCompound> getMap() // { // return questList; // } // // @SideOnly(Side.CLIENT) // public void setQuestStatusClient(EntityPlayer player, String questName, int questStatus) // { // HashMap<String, Integer> map = questProgress.get(player.username); // if(map == null) // map = new HashMap<String, Integer>(); // map.put(questName, questStatus); // questProgress.put(player.username, map); // } // // @SideOnly(Side.CLIENT) // public int getQuestStatusClient(EntityPlayer player, String questName) // { // HashMap<String, Integer> map; // if(questProgress.containsKey(player.username)) // { // map = questProgress.get(player.username); // } // else // map = new HashMap<String, Integer>(); // // if(map.containsKey(questName)) // return map.get(questName); // return 0; // } // // @SideOnly(Side.CLIENT) // public boolean isQuestActiveClient(EntityPlayer player, String questName) // { // if(getQuestStatusClient(player, questName) != 3 && getQuestStatusClient(player, questName) != 0) // return true; // return false; // } // } // Path: Journey of Legends/aginsun/journey/universal/handlers/LivingDeathEventHandler.java import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingDeathEvent; import aginsun.journey.server.api.QuestHandler; package aginsun.journey.universal.handlers; public class LivingDeathEventHandler { @ForgeSubscribe public void onLivingDeath(LivingDeathEvent event) { if(event.source.getDamageType().equals("player")){ EntityPlayer player = (EntityPlayer)event.source.getSourceOfDamage(); if(event.entityLiving instanceof EntityZombie){
if(QuestHandler.instance().isQuestActive(player, "Hunting"))
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/entities/InitEntities.java
// Path: Journey of Legends/aginsun/journey/JourneyofLegends.java // @Mod(modid = Utils.modID, version = Utils.Version, name = Utils.Name) // @NetworkMod(channels = { Utils.modID },clientSideRequired = true, serverSideRequired = true, packetHandler = PacketHandler.class) // public class JourneyofLegends // { // @Instance (Utils.modID) // public static JourneyofLegends instance = new JourneyofLegends(); // // @SidedProxy(clientSide="aginsun.journey.client.core.ClientProxy",serverSide="aginsun.journey.core.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void PreInit(FMLPreInitializationEvent event) // { // ConfigFileJoL.config(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) // { // InitEntities.Init(); // // InitBlocks.Init(); // // InitItems.Init(); // // NetworkRegistry.instance().registerGuiHandler(instance, proxy); // // TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); // // MinecraftForge.EVENT_BUS.register(new EntityLivingHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingAttackEventHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingDeathEventHandler()); // // proxy.RegisterRenderers(); // // WorldgenChests.Init(); // } // // @EventHandler // public void PostInit(FMLPostInitializationEvent event) // { // proxy.registerPostInit(); // // GoldValueHandler.setGoldValues(); // // QuestRegistry.InitQuests(); // } // // @EventHandler // public void serverStarting(FMLServerStartingEvent event) // { // CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager(); // commandManager.registerCommand(new CommandJoLHandler()); // } // // @EventHandler // public void serverStarted(FMLServerStartedEvent event) // { // GameRegistry.registerPlayerTracker(new SaveHandler()); // GameRegistry.registerPickupHandler(new PickupHandler()); // } // }
import aginsun.journey.JourneyofLegends; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry;
package aginsun.journey.universal.entities; public class InitEntities { public static void Init() { GameRegistry.registerTileEntity(TileEntitySell.class, "TeSell"); EntityRegistry.registerGlobalEntityID(EntityGuildMaster.class, "GuildMaster", 215, 255, 255);
// Path: Journey of Legends/aginsun/journey/JourneyofLegends.java // @Mod(modid = Utils.modID, version = Utils.Version, name = Utils.Name) // @NetworkMod(channels = { Utils.modID },clientSideRequired = true, serverSideRequired = true, packetHandler = PacketHandler.class) // public class JourneyofLegends // { // @Instance (Utils.modID) // public static JourneyofLegends instance = new JourneyofLegends(); // // @SidedProxy(clientSide="aginsun.journey.client.core.ClientProxy",serverSide="aginsun.journey.core.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void PreInit(FMLPreInitializationEvent event) // { // ConfigFileJoL.config(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) // { // InitEntities.Init(); // // InitBlocks.Init(); // // InitItems.Init(); // // NetworkRegistry.instance().registerGuiHandler(instance, proxy); // // TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); // // MinecraftForge.EVENT_BUS.register(new EntityLivingHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingAttackEventHandler()); // // MinecraftForge.EVENT_BUS.register(new LivingDeathEventHandler()); // // proxy.RegisterRenderers(); // // WorldgenChests.Init(); // } // // @EventHandler // public void PostInit(FMLPostInitializationEvent event) // { // proxy.registerPostInit(); // // GoldValueHandler.setGoldValues(); // // QuestRegistry.InitQuests(); // } // // @EventHandler // public void serverStarting(FMLServerStartingEvent event) // { // CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager(); // commandManager.registerCommand(new CommandJoLHandler()); // } // // @EventHandler // public void serverStarted(FMLServerStartedEvent event) // { // GameRegistry.registerPlayerTracker(new SaveHandler()); // GameRegistry.registerPickupHandler(new PickupHandler()); // } // } // Path: Journey of Legends/aginsun/journey/universal/entities/InitEntities.java import aginsun.journey.JourneyofLegends; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; package aginsun.journey.universal.entities; public class InitEntities { public static void Init() { GameRegistry.registerTileEntity(TileEntitySell.class, "TeSell"); EntityRegistry.registerGlobalEntityID(EntityGuildMaster.class, "GuildMaster", 215, 255, 255);
EntityRegistry.registerModEntity(EntityGuildMaster.class, "GuildMaster", 215, JourneyofLegends.instance, 250, 5, false);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/packets/PacketExperience.java
// Path: Journey of Legends/aginsun/journey/server/api/ExperienceKeeper.java // public class ExperienceKeeper // { // private static HashMap<String, Integer> ExperienceMap = new HashMap<String, Integer>(); // // public static void addExperience(EntityPlayer player) // { // int Experience = getExperience(player); // Experience++; // setExperience(player, Experience); // } // // public static void addExperience(EntityPlayer player, int experience) // { // int Experience = getExperience(player); // Experience += experience; // setExperience(player, Experience); // } // // public static void setExperience(EntityPlayer player, int experience) // { // ExperienceMap.put(player.username, experience); // } // // public static int getExperience(EntityPlayer player) // { // if(!ExperienceMap.containsKey(player.username)) // { // return 0; // } // return ExperienceMap.get(player.username); // } // // public static int getExperience(String username) // { // if(!ExperienceMap.containsKey(username)) // { // return 0; // } // return ExperienceMap.get(username); // } // }
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.ExperienceKeeper; import cpw.mods.fml.common.network.Player;
package aginsun.journey.universal.packets; public class PacketExperience extends PacketJoL { private int Experience; private String username; public PacketExperience() { super(PacketType.EXPERIENCE, false); } public PacketExperience(String username, int Experience) { super(PacketType.EXPERIENCE, false); this.username = username; this.Experience = Experience; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.Experience = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(Experience); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
// Path: Journey of Legends/aginsun/journey/server/api/ExperienceKeeper.java // public class ExperienceKeeper // { // private static HashMap<String, Integer> ExperienceMap = new HashMap<String, Integer>(); // // public static void addExperience(EntityPlayer player) // { // int Experience = getExperience(player); // Experience++; // setExperience(player, Experience); // } // // public static void addExperience(EntityPlayer player, int experience) // { // int Experience = getExperience(player); // Experience += experience; // setExperience(player, Experience); // } // // public static void setExperience(EntityPlayer player, int experience) // { // ExperienceMap.put(player.username, experience); // } // // public static int getExperience(EntityPlayer player) // { // if(!ExperienceMap.containsKey(player.username)) // { // return 0; // } // return ExperienceMap.get(player.username); // } // // public static int getExperience(String username) // { // if(!ExperienceMap.containsKey(username)) // { // return 0; // } // return ExperienceMap.get(username); // } // } // Path: Journey of Legends/aginsun/journey/universal/packets/PacketExperience.java import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import aginsun.journey.server.api.ExperienceKeeper; import cpw.mods.fml.common.network.Player; package aginsun.journey.universal.packets; public class PacketExperience extends PacketJoL { private int Experience; private String username; public PacketExperience() { super(PacketType.EXPERIENCE, false); } public PacketExperience(String username, int Experience) { super(PacketType.EXPERIENCE, false); this.username = username; this.Experience = Experience; } public void readData(DataInputStream data) throws IOException { this.username = data.readUTF(); this.Experience = data.readInt(); } public void writeData(DataOutputStream dos) throws IOException { dos.writeUTF(username); dos.writeInt(Experience); } public void execute(INetworkManager network, Player player) { EntityPlayer thePlayer = (EntityPlayer)player;
ExperienceKeeper.setExperience(thePlayer, Experience);
aginsun/Journey-of-Legends
Journey of Legends/aginsun/journey/universal/worldgen/WorldGenStart.java
// Path: Journey of Legends/aginsun/journey/universal/entities/EntityGuildMaster.java // public class EntityGuildMaster extends EntityCreature // { // public World world; // public Quest quest; // // public EntityGuildMaster(World par1World) // { // super(par1World); // world = par1World; // isImmuneToFire = false; // setEntityHealth(25.0F); // } // // protected boolean canDespawn() // { // return false; // } // // public boolean canInteractWith(EntityPlayer player) // { // if(isDead) // { // return false; // } // else // { // return player.getDistanceSqToEntity(this) <= 64D; // } // } // // public boolean canBePushed() // { // return false; // } // // public boolean isMovementCeased() // { // return true; // } // // @SideOnly(Side.CLIENT) // public boolean interact(EntityPlayer player) // { // if(canInteractWith(player)) // { // if(QuestHandler.instance().isQuestActiveClient(player, QuestRegistry.getQuest(4).setPlayer(player).getQuestName())) // { // quest = QuestRegistry.getQuest(4).setPlayer(player); // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketQuestData(player.username, quest.getQuestName(), 2))); // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(quest.getQuestName(), quest, true)); // return true; // } // if(QuestHandler.instance().getQuestStatus(player, "The beginning of a great adventure") != 3) // quest = QuestRegistry.getQuest(1).setPlayer(player); // else if(QuestHandler.instance().getQuestStatus(player, "Hunting") != 3) // quest = QuestRegistry.getQuest(3).setPlayer(player); // else if(QuestHandler.instance().getQuestStatus(player, "Leveling") != 3) // quest = QuestRegistry.getQuest(2).setPlayer(player); // else if(QuestHandler.instance().getQuestStatus(player, "Progression") != 3) // quest = QuestRegistry.getQuest(5).setPlayer(player); // if(quest != null) // quest.update(); // } // return true; // } // }
import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; import aginsun.journey.universal.entities.EntityGuildMaster;
world.setBlock(i + 0, j + 8, k + 4, 53); world.setBlock(i + 0, j + 8, k + 3, 5); world.setBlock(i + 0, j + 8, k + 2, 53); world.setBlock(i + 1, j + 8, k + 4, 53); world.setBlock(i + 1, j + 8, k + 3, 5); world.setBlock(i + 1, j + 8, k + 2, 53); world.setBlock(i + 2, j + 8, k + 4, 53); world.setBlock(i + 2, j + 8, k + 3, 5); world.setBlock(i + 2, j + 8, k + 2, 53); world.setBlock(i + 3, j + 8, k + 4, 53); world.setBlock(i + 3, j + 8, k + 3, 5); world.setBlock(i + 3, j + 8, k + 2, 53); world.setBlock(i + 4, j + 8, k + 4, 53); world.setBlock(i + 4, j + 8, k + 3, 5); world.setBlock(i + 4, j + 8, k + 2, 53); world.setBlock(i + 5, j + 8, k + 4, 53); world.setBlock(i + 5, j + 8, k + 3, 5); world.setBlock(i + 5, j + 8, k + 2, 53); world.setBlock(i + 6, j + 8, k + 4, 53); world.setBlock(i + 6, j + 8, k + 3, 5); world.setBlock(i + 6, j + 8, k + 2, 53); world.setBlock(i + 7, j + 8, k + 4, 53); world.setBlock(i + 7, j + 8, k + 3, 5); world.setBlock(i + 7, j + 8, k + 2, 53); world.setBlock(i + 8, j + 8, k + 4, 53); world.setBlock(i + 8, j + 8, k + 3, 5); world.setBlock(i + 8, j + 8, k + 2, 53); world.setBlock(i + 9, j + 8, k + 4, 53); world.setBlock(i + 9, j + 8, k + 3, 5);
// Path: Journey of Legends/aginsun/journey/universal/entities/EntityGuildMaster.java // public class EntityGuildMaster extends EntityCreature // { // public World world; // public Quest quest; // // public EntityGuildMaster(World par1World) // { // super(par1World); // world = par1World; // isImmuneToFire = false; // setEntityHealth(25.0F); // } // // protected boolean canDespawn() // { // return false; // } // // public boolean canInteractWith(EntityPlayer player) // { // if(isDead) // { // return false; // } // else // { // return player.getDistanceSqToEntity(this) <= 64D; // } // } // // public boolean canBePushed() // { // return false; // } // // public boolean isMovementCeased() // { // return true; // } // // @SideOnly(Side.CLIENT) // public boolean interact(EntityPlayer player) // { // if(canInteractWith(player)) // { // if(QuestHandler.instance().isQuestActiveClient(player, QuestRegistry.getQuest(4).setPlayer(player).getQuestName())) // { // quest = QuestRegistry.getQuest(4).setPlayer(player); // PacketDispatcher.sendPacketToServer(PacketType.populatePacket(new PacketQuestData(player.username, quest.getQuestName(), 2))); // FMLCommonHandler.instance().showGuiScreen(new GuiQuest(quest.getQuestName(), quest, true)); // return true; // } // if(QuestHandler.instance().getQuestStatus(player, "The beginning of a great adventure") != 3) // quest = QuestRegistry.getQuest(1).setPlayer(player); // else if(QuestHandler.instance().getQuestStatus(player, "Hunting") != 3) // quest = QuestRegistry.getQuest(3).setPlayer(player); // else if(QuestHandler.instance().getQuestStatus(player, "Leveling") != 3) // quest = QuestRegistry.getQuest(2).setPlayer(player); // else if(QuestHandler.instance().getQuestStatus(player, "Progression") != 3) // quest = QuestRegistry.getQuest(5).setPlayer(player); // if(quest != null) // quest.update(); // } // return true; // } // } // Path: Journey of Legends/aginsun/journey/universal/worldgen/WorldGenStart.java import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; import aginsun.journey.universal.entities.EntityGuildMaster; world.setBlock(i + 0, j + 8, k + 4, 53); world.setBlock(i + 0, j + 8, k + 3, 5); world.setBlock(i + 0, j + 8, k + 2, 53); world.setBlock(i + 1, j + 8, k + 4, 53); world.setBlock(i + 1, j + 8, k + 3, 5); world.setBlock(i + 1, j + 8, k + 2, 53); world.setBlock(i + 2, j + 8, k + 4, 53); world.setBlock(i + 2, j + 8, k + 3, 5); world.setBlock(i + 2, j + 8, k + 2, 53); world.setBlock(i + 3, j + 8, k + 4, 53); world.setBlock(i + 3, j + 8, k + 3, 5); world.setBlock(i + 3, j + 8, k + 2, 53); world.setBlock(i + 4, j + 8, k + 4, 53); world.setBlock(i + 4, j + 8, k + 3, 5); world.setBlock(i + 4, j + 8, k + 2, 53); world.setBlock(i + 5, j + 8, k + 4, 53); world.setBlock(i + 5, j + 8, k + 3, 5); world.setBlock(i + 5, j + 8, k + 2, 53); world.setBlock(i + 6, j + 8, k + 4, 53); world.setBlock(i + 6, j + 8, k + 3, 5); world.setBlock(i + 6, j + 8, k + 2, 53); world.setBlock(i + 7, j + 8, k + 4, 53); world.setBlock(i + 7, j + 8, k + 3, 5); world.setBlock(i + 7, j + 8, k + 2, 53); world.setBlock(i + 8, j + 8, k + 4, 53); world.setBlock(i + 8, j + 8, k + 3, 5); world.setBlock(i + 8, j + 8, k + 2, 53); world.setBlock(i + 9, j + 8, k + 4, 53); world.setBlock(i + 9, j + 8, k + 3, 5);
EntityLiving entity = new EntityGuildMaster(world);
basgren/railways
src/net/bitpot/railways/actions/CopyFullRoutePathAction.java
// Path: src/net/bitpot/railways/models/Route.java // public class Route implements NavigationItem { // // private final Module module; // private final RequestMethod requestMethod; // private final String path; // private final String routeName; // // @Nullable // private RailsEngine myParentEngine = null; // // // Cached path and action text chunks. // private List<TextChunk> pathChunks = null; // private List<TextChunk> actionChunks = null; // // // public Route(@Nullable Module module, RequestMethod requestMethod, String path, // String name) { // this.module = module; // // this.requestMethod = requestMethod; // this.path = path; // this.routeName = name; // } // // // /** // * Returns module the route belongs to. // * @return Route module // */ // public Module getModule() { // return module; // } // // // @NotNull // public RequestMethod getRequestMethod() { // return requestMethod; // } // // // /** // * Returns displayable text for route action in short format. Short format // * is used in routes table. // * // * @return Displayable text for route action, ex. "users#create" // */ // public String getActionTitle() { // return getQualifiedActionTitle(); // } // // // /** // * Returns qualified name for route action. // * // * @return Displayable text for route action, ex. "UsersController#create" // */ // public String getQualifiedActionTitle() { // return ""; // } // // // /** // * Returns displayable name for navigation list. // * // * @return Display name of current route. // */ // @Nullable // @Override // public String getName() { // return path; // } // // // @Nullable // @Override // public ItemPresentation getPresentation() { // final Route route = this; // // return new ItemPresentation() { // @Nullable // @Override // public String getPresentableText() { // return path; // } // // // @Nullable // @Override // public String getLocationString() { // return getActionTitle(); // } // // // @Nullable // @Override // public Icon getIcon(boolean unused) { // return route.getRequestMethod().getIcon(); // } // }; // } // // // @Override // public void navigate(boolean requestFocus) { // // This method should be overridden in subclasses that support navigation. // } // // // @Override // public boolean canNavigate() { // return false; // } // // // @Override // public boolean canNavigateToSource() { // return canNavigate(); // } // // // public String getPath() { // return path; // } // // public String getPathWithMethod() { // String path = RailwaysUtils.stripRequestFormat(getPath()); // // if (getRequestMethod() == RequestMethods.ANY) // return path; // // return String.format("%s %s", getRequestMethod().getName(), path); // } // // // public List<TextChunk> getPathChunks() { // if (pathChunks == null) // pathChunks = RoutePathParser.getInstance().parse(getPath()); // // return pathChunks; // } // // // public List<TextChunk> getActionChunks() { // if (actionChunks == null) // actionChunks = RouteActionParser.getInstance().parse(getActionTitle()); // // return actionChunks; // } // // // public String getRouteName() { // if (getParentEngine() != null) // return getParentEngine().getNamespace() + "." + routeName; // // return routeName; // } // // // /** // * Checks route action status and sets isActionDeclarationFound flag. // * // * @param app Rails application which will be checked for controller action. // */ // public void updateActionStatus(RailsApp app) { // // Should be overridden in subclasses if an update is required. // } // // // @Nullable // public RailsEngine getParentEngine() { // return myParentEngine; // } // // public void setParentEngine(RailsEngine parentEngine) { // myParentEngine = parentEngine; // } // // // public Icon getActionIcon() { // return RailwaysIcons.NODE_UNKNOWN; // } // }
import net.bitpot.railways.models.Route;
package net.bitpot.railways.actions; public class CopyFullRoutePathAction extends CopyRouteActionBase { @Override
// Path: src/net/bitpot/railways/models/Route.java // public class Route implements NavigationItem { // // private final Module module; // private final RequestMethod requestMethod; // private final String path; // private final String routeName; // // @Nullable // private RailsEngine myParentEngine = null; // // // Cached path and action text chunks. // private List<TextChunk> pathChunks = null; // private List<TextChunk> actionChunks = null; // // // public Route(@Nullable Module module, RequestMethod requestMethod, String path, // String name) { // this.module = module; // // this.requestMethod = requestMethod; // this.path = path; // this.routeName = name; // } // // // /** // * Returns module the route belongs to. // * @return Route module // */ // public Module getModule() { // return module; // } // // // @NotNull // public RequestMethod getRequestMethod() { // return requestMethod; // } // // // /** // * Returns displayable text for route action in short format. Short format // * is used in routes table. // * // * @return Displayable text for route action, ex. "users#create" // */ // public String getActionTitle() { // return getQualifiedActionTitle(); // } // // // /** // * Returns qualified name for route action. // * // * @return Displayable text for route action, ex. "UsersController#create" // */ // public String getQualifiedActionTitle() { // return ""; // } // // // /** // * Returns displayable name for navigation list. // * // * @return Display name of current route. // */ // @Nullable // @Override // public String getName() { // return path; // } // // // @Nullable // @Override // public ItemPresentation getPresentation() { // final Route route = this; // // return new ItemPresentation() { // @Nullable // @Override // public String getPresentableText() { // return path; // } // // // @Nullable // @Override // public String getLocationString() { // return getActionTitle(); // } // // // @Nullable // @Override // public Icon getIcon(boolean unused) { // return route.getRequestMethod().getIcon(); // } // }; // } // // // @Override // public void navigate(boolean requestFocus) { // // This method should be overridden in subclasses that support navigation. // } // // // @Override // public boolean canNavigate() { // return false; // } // // // @Override // public boolean canNavigateToSource() { // return canNavigate(); // } // // // public String getPath() { // return path; // } // // public String getPathWithMethod() { // String path = RailwaysUtils.stripRequestFormat(getPath()); // // if (getRequestMethod() == RequestMethods.ANY) // return path; // // return String.format("%s %s", getRequestMethod().getName(), path); // } // // // public List<TextChunk> getPathChunks() { // if (pathChunks == null) // pathChunks = RoutePathParser.getInstance().parse(getPath()); // // return pathChunks; // } // // // public List<TextChunk> getActionChunks() { // if (actionChunks == null) // actionChunks = RouteActionParser.getInstance().parse(getActionTitle()); // // return actionChunks; // } // // // public String getRouteName() { // if (getParentEngine() != null) // return getParentEngine().getNamespace() + "." + routeName; // // return routeName; // } // // // /** // * Checks route action status and sets isActionDeclarationFound flag. // * // * @param app Rails application which will be checked for controller action. // */ // public void updateActionStatus(RailsApp app) { // // Should be overridden in subclasses if an update is required. // } // // // @Nullable // public RailsEngine getParentEngine() { // return myParentEngine; // } // // public void setParentEngine(RailsEngine parentEngine) { // myParentEngine = parentEngine; // } // // // public Icon getActionIcon() { // return RailwaysIcons.NODE_UNKNOWN; // } // } // Path: src/net/bitpot/railways/actions/CopyFullRoutePathAction.java import net.bitpot.railways.models.Route; package net.bitpot.railways.actions; public class CopyFullRoutePathAction extends CopyRouteActionBase { @Override
public String getRouteValue(Route route) {
basgren/railways
src/net/bitpot/railways/routesView/RoutesViewToolWindowFactory.java
// Path: src/net/bitpot/railways/utils/RailwaysUtils.java // public class RailwaysUtils { // @SuppressWarnings("unused") // private final static Logger log = Logger.getInstance(RailwaysUtils.class.getName()); // // public final static StringFormatter STRIP_REQUEST_FORMAT = RailwaysUtils::stripRequestFormat; // // /** // * Returns true if specified project has at least one Ruby on Rails module. // * // * @param project Project which should be checked for Rails modules. // * @return True if a project has at least one Ruby on Rails module. // */ // public static boolean hasRailsModules(Project project) { // Module[] modules = ModuleManager.getInstance(project).getModules(); // for (Module m : modules) // if (RailsApp.fromModule(m) != null) // return true; // // return false; // } // // // /** // * Internally used method that runs rake task and gets its output. This // * method should be called from backgroundable task. // * // * @param module Rails module for which rake task should be run. // * @return Output of 'rake routes'. // */ // @Nullable // public static ProcessOutput queryRakeRoutes(Module module, // String routesTaskName, String railsEnv) { // // Get root path of Rails application from module. // RailsApp app = RailsApp.fromModule(module); // if ((app == null) || (app.getRailsApplicationRoot() == null)) // return null; // // String moduleContentRoot = app.getRailsApplicationRoot().getPresentableUrl(); // // ModuleRootManager mManager = ModuleRootManager.getInstance(module); // Sdk sdk = mManager.getSdk(); // if (sdk == null) { // Notifications.Bus.notify(new Notification("Railways", // "Railways error", // "Cannot update route list for '" + module.getName() + // "' module, because its SDK is not set", // NotificationType.ERROR) // , module.getProject()); // return null; // } // // try { // railsEnv = (railsEnv == null) ? "" : "RAILS_ENV=" + railsEnv; // // // Will work on IntelliJ platform since 2017.3 // return RubyGemExecutionContext.create(sdk, "rails") // .withModule(module) // .withWorkingDirPath(moduleContentRoot) // .withExecutionMode(new ExecutionModes.SameThreadMode()) // .withArguments(routesTaskName, "--trace", railsEnv) // .executeScript(); // } catch (Exception e) { // e.printStackTrace(); // } // // return null; // } // // // /** // * Shows a dialog with 'rake routes' error stacktrace. // * // * @param routesManager RoutesManager which error stacktrace should be // * displayed. // */ // public static void showErrorInfo(@NotNull RoutesManager routesManager) { // ErrorInfoDlg.showError("Error information:", // routesManager.getParseErrorStackTrace()); // } // // // /** // * Invokes action with specified ID. This method provides very simple // * implementation of invoking action manually when ActionEvent and // * DataContext are unavailable. Created DataContext in this method provides // * only CommonDataKeys.PROJECT value. // * // * @param actionId ID of action to invoke // * @param project Current project // */ // public static void invokeAction(String actionId, final Project project) { // AnAction act = ActionManager.getInstance().getAction(actionId); // // // For simple actions which don't heavily use data context, we can create // // it manually. // DataContext dataContext = dataId -> { // if (CommonDataKeys.PROJECT.is(dataId)) // return project; // // return null; // }; // // act.actionPerformed(new AnActionEvent(null, dataContext, // ActionPlaces.UNKNOWN, act.getTemplatePresentation(), // ActionManager.getInstance(), 0)); // } // // // public static void updateActionsStatus(Module module, RouteList routeList) { // RailsApp app = RailsApp.fromModule(module); // if ((app == null) || (DumbService.isDumb(module.getProject()))) // return; // // // TODO: investigate multiple calls of this method when switching focus from code to tool window without any changes. // // for (Route route: routeList) // route.updateActionStatus(app); // } // // // private final static String FORMAT_STR = "(.:format)"; // // @NotNull // public static String stripRequestFormat(@NotNull String routePath) { // int endIndex = routePath.length() - FORMAT_STR.length(); // if (routePath.indexOf(FORMAT_STR) == endIndex) // return routePath.substring(0, endIndex); // // return routePath; // } // // }
import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowFactory; import net.bitpot.railways.utils.RailwaysUtils; import org.jetbrains.annotations.NotNull;
package net.bitpot.railways.routesView; public class RoutesViewToolWindowFactory implements ToolWindowFactory { @Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { RoutesView.getInstance(project).initToolWindow(toolWindow); } @Override public boolean isApplicable(@NotNull Project project) {
// Path: src/net/bitpot/railways/utils/RailwaysUtils.java // public class RailwaysUtils { // @SuppressWarnings("unused") // private final static Logger log = Logger.getInstance(RailwaysUtils.class.getName()); // // public final static StringFormatter STRIP_REQUEST_FORMAT = RailwaysUtils::stripRequestFormat; // // /** // * Returns true if specified project has at least one Ruby on Rails module. // * // * @param project Project which should be checked for Rails modules. // * @return True if a project has at least one Ruby on Rails module. // */ // public static boolean hasRailsModules(Project project) { // Module[] modules = ModuleManager.getInstance(project).getModules(); // for (Module m : modules) // if (RailsApp.fromModule(m) != null) // return true; // // return false; // } // // // /** // * Internally used method that runs rake task and gets its output. This // * method should be called from backgroundable task. // * // * @param module Rails module for which rake task should be run. // * @return Output of 'rake routes'. // */ // @Nullable // public static ProcessOutput queryRakeRoutes(Module module, // String routesTaskName, String railsEnv) { // // Get root path of Rails application from module. // RailsApp app = RailsApp.fromModule(module); // if ((app == null) || (app.getRailsApplicationRoot() == null)) // return null; // // String moduleContentRoot = app.getRailsApplicationRoot().getPresentableUrl(); // // ModuleRootManager mManager = ModuleRootManager.getInstance(module); // Sdk sdk = mManager.getSdk(); // if (sdk == null) { // Notifications.Bus.notify(new Notification("Railways", // "Railways error", // "Cannot update route list for '" + module.getName() + // "' module, because its SDK is not set", // NotificationType.ERROR) // , module.getProject()); // return null; // } // // try { // railsEnv = (railsEnv == null) ? "" : "RAILS_ENV=" + railsEnv; // // // Will work on IntelliJ platform since 2017.3 // return RubyGemExecutionContext.create(sdk, "rails") // .withModule(module) // .withWorkingDirPath(moduleContentRoot) // .withExecutionMode(new ExecutionModes.SameThreadMode()) // .withArguments(routesTaskName, "--trace", railsEnv) // .executeScript(); // } catch (Exception e) { // e.printStackTrace(); // } // // return null; // } // // // /** // * Shows a dialog with 'rake routes' error stacktrace. // * // * @param routesManager RoutesManager which error stacktrace should be // * displayed. // */ // public static void showErrorInfo(@NotNull RoutesManager routesManager) { // ErrorInfoDlg.showError("Error information:", // routesManager.getParseErrorStackTrace()); // } // // // /** // * Invokes action with specified ID. This method provides very simple // * implementation of invoking action manually when ActionEvent and // * DataContext are unavailable. Created DataContext in this method provides // * only CommonDataKeys.PROJECT value. // * // * @param actionId ID of action to invoke // * @param project Current project // */ // public static void invokeAction(String actionId, final Project project) { // AnAction act = ActionManager.getInstance().getAction(actionId); // // // For simple actions which don't heavily use data context, we can create // // it manually. // DataContext dataContext = dataId -> { // if (CommonDataKeys.PROJECT.is(dataId)) // return project; // // return null; // }; // // act.actionPerformed(new AnActionEvent(null, dataContext, // ActionPlaces.UNKNOWN, act.getTemplatePresentation(), // ActionManager.getInstance(), 0)); // } // // // public static void updateActionsStatus(Module module, RouteList routeList) { // RailsApp app = RailsApp.fromModule(module); // if ((app == null) || (DumbService.isDumb(module.getProject()))) // return; // // // TODO: investigate multiple calls of this method when switching focus from code to tool window without any changes. // // for (Route route: routeList) // route.updateActionStatus(app); // } // // // private final static String FORMAT_STR = "(.:format)"; // // @NotNull // public static String stripRequestFormat(@NotNull String routePath) { // int endIndex = routePath.length() - FORMAT_STR.length(); // if (routePath.indexOf(FORMAT_STR) == endIndex) // return routePath.substring(0, endIndex); // // return routePath; // } // // } // Path: src/net/bitpot/railways/routesView/RoutesViewToolWindowFactory.java import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowFactory; import net.bitpot.railways.utils.RailwaysUtils; import org.jetbrains.annotations.NotNull; package net.bitpot.railways.routesView; public class RoutesViewToolWindowFactory implements ToolWindowFactory { @Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { RoutesView.getInstance(project).initToolWindow(toolWindow); } @Override public boolean isApplicable(@NotNull Project project) {
return RailwaysUtils.hasRailsModules(project);
basgren/railways
src/net/bitpot/railways/models/requestMethods/PutRequestMethod.java
// Path: src/net/bitpot/railways/gui/RailwaysIcons.java // public class RailwaysIcons { // private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/"; // // private static Icon pluginIcon(String name) { // return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class); // } // // public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png"); // public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png"); // public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png"); // public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png"); // public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png"); // public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration; // // // Icons for table items // public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class; // public static final Icon NODE_ERROR = AllIcons.General.Error; // public static final Icon NODE_METHOD = AllIcons.Nodes.Method; // public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin; // public static final Icon NODE_REDIRECT = pluginIcon("redirect.png"); // public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method; // public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png"); // // public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class); // public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class); // }
import net.bitpot.railways.gui.RailwaysIcons; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package net.bitpot.railways.models.requestMethods; public class PutRequestMethod implements RequestMethod { @Override public Icon getIcon() {
// Path: src/net/bitpot/railways/gui/RailwaysIcons.java // public class RailwaysIcons { // private static final String PLUGIN_ICONS_PATH = "/net/bitpot/railways/icons/"; // // private static Icon pluginIcon(String name) { // return IconLoader.getIcon(PLUGIN_ICONS_PATH + name, RailwaysIcons.class); // } // // public static final Icon HTTP_METHOD_ANY = pluginIcon("method_any.png"); // public static final Icon HTTP_METHOD_GET = pluginIcon("method_get.png"); // public static final Icon HTTP_METHOD_POST = pluginIcon("method_post.png"); // public static final Icon HTTP_METHOD_PUT = pluginIcon("method_put.png"); // public static final Icon HTTP_METHOD_DELETE = pluginIcon("method_delete.png"); // public static final Icon RAKE = RubyIcons.Rake.Rake_runConfiguration; // // // Icons for table items // public static final Icon NODE_CONTROLLER = AllIcons.Nodes.Class; // public static final Icon NODE_ERROR = AllIcons.General.Error; // public static final Icon NODE_METHOD = AllIcons.Nodes.Method; // public static final Icon NODE_MOUNTED_ENGINE = AllIcons.Nodes.Plugin; // public static final Icon NODE_REDIRECT = pluginIcon("redirect.png"); // public static final Icon NODE_ROUTE_ACTION = RubyIcons.Rails.ProjectView.Action_method; // public static final Icon NODE_UNKNOWN = pluginIcon("unknown.png"); // // public static final Icon UPDATE = IconLoader.getIcon("/actions/sync.png", RailwaysIcons.class); // public static final Icon SUSPEND = IconLoader.getIcon("/actions/suspend.png", RailwaysIcons.class); // } // Path: src/net/bitpot/railways/models/requestMethods/PutRequestMethod.java import net.bitpot.railways.gui.RailwaysIcons; import org.jetbrains.annotations.NotNull; import javax.swing.*; package net.bitpot.railways.models.requestMethods; public class PutRequestMethod implements RequestMethod { @Override public Icon getIcon() {
return RailwaysIcons.HTTP_METHOD_PUT;