Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Project Cleanup #10

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .classpath

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk
.idea/**
SketchMap-FULL.iml
SketchMap/SketchMap.iml
target/
.classpath
.project
.settings
24 changes: 0 additions & 24 deletions .project

This file was deleted.

12 changes: 0 additions & 12 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: java
jdk:
- oraclejdk8
sudo: false
addons:
apt:
packages:
- oracle-java8-installer
deploy:
provider: releases
api_key:
secure: n9m/falG9fjo2HyQv/4Tiy13sWG+zXSySt4pE1MHXkTMuyR3SqCKoKcSwNVpgCkF5dnZpCiWAd19JSkjUUDDoE5vVTqFC8yB4cO8IIdF7Z0gowOA5Pgs7idSFGrut8o/gUCJdHLoHE2tNQlKcTWXNWaEke9mqmCFiEbhy1Dak62qd0mS90il/9r4fmVcXlPT/COayBbLqFcVZQg7ppVhexoBWjy8VO7UYrl1xmiWu8aM4fO4gta38/5h7T6b3hfRKHJN3hJ4nnMwW0F26d0k2K3OYzojkWlY6i5xwxTIwDhGaXID89slUkAfQZ4At9yMsCbI+dj7jc2uz791AUookWTxcMhZ01O7y3dCRRSMOQ7CCnJftJ1Wx9BntyTGPP5H4144LtD8+kzf5A/jr0mcEYvALo6gfMjJ22XI7NnPk6dRpHoP3A8v5/m0Za+DfcmezBTfXDDMB2afzVVAdDaK1WbfFZeR8GRB5DfOqL9oEidxp3QZejKLAHRUCYATIqAWSRinyBNH+5aJTk8t2/++TurDpSOGCKuO986VoNe0bOX6TYIweKYC3b9vSQkCL3eD6px0lr3xvTaV3RvrVm1QXPVVwX89IIHgyTzCOLyZVwaBXdUqjTuLjqU2wAGlV/z1/lktixfkqaIxfX87BdxtvRPPl6xEgvnNYaxvHK4kGSk=
file:
- "./target/SketchMap.jar"
skip_cleanup: true
overwrite: true
on:
tags: true
repo: Craftstuebchen/SketchMap
Binary file not shown.
Binary file not shown.
Binary file not shown.
63 changes: 63 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.ebaldino</groupId>
<artifactId>SketchMap</artifactId>
<version>3.3</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>${artifactId}</finalName>
<defaultGoal>clean package install</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>bukkit-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>commons-io-repo</id>
<url>https://mvnrepository.com/artifact/commons-io/commons-io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package com.mcplugindev.slipswhitley.sketchmap;
package io.github.ebaldino.SketchMap;

import io.github.ebaldino.SketchMap.file.SketchMapFileException;
import io.github.ebaldino.SketchMap.map.RelativeLocation;
import io.github.ebaldino.SketchMap.map.SketchMap;
import io.github.ebaldino.SketchMap.map.SketchMap.BaseFormat;

import java.awt.image.BufferedImage;
import java.io.File;
Expand All @@ -14,11 +19,6 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import com.mcplugindev.slipswhitley.sketchmap.file.SketchMapFileException;
import com.mcplugindev.slipswhitley.sketchmap.map.RelativeLocation;
import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap;
import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap.BaseFormat;

public class SketchMapAPI {

public static SketchMap getMapByID(String id) {
Expand Down Expand Up @@ -64,10 +64,16 @@ public static List<ItemStack> getOrderedItemSet(SketchMap map) {
return items;
}

/**
* loadSketchMapFromFile
* @param file
* @return
* @throws SketchMapFileException
*/
public static SketchMap loadSketchMapFromFile(File file) throws SketchMapFileException {

YamlConfiguration config = null;
try {
try {
config = YamlConfiguration.loadConfiguration(file);
}
catch (Exception ex) {
Expand All @@ -83,8 +89,7 @@ public static SketchMap loadSketchMapFromFile(File file) throws SketchMapFileExc
"map-image",
};




for(String field : fieldSet) {
if(!config.isSet(field)) {
throw new SketchMapFileException("Unable to load SketchMap file \"" + file.getName()
Expand Down Expand Up @@ -118,35 +123,41 @@ public static SketchMap loadSketchMapFromFile(File file) throws SketchMapFileExc
+ "\" invalid field \"map-collection\"");
}

// All fields present, create new map
Map<Short, RelativeLocation> mapCollection = new HashMap<Short, RelativeLocation>();

// Load map from file, each pane is called a "map" here, so we're iterating through the panes in map-collection
for(String map : mapList) {
String[] split = map.split(" ");
if(split.length != 2) {
throw new SketchMapFileException("Unable to load SketchMap file \"" + file.getName()
+ "\" cannot parse field in \"map-colection\"");
}

// Get the location of the pane in the image's grid (matrix)
RelativeLocation loc = RelativeLocation.fromString(split[0]);

if(loc == null) {
throw new SketchMapFileException("Unable to load SketchMap file \"" + file.getName()
+ "\" cannot parse field in \"map-colection\"");
+ "\" cannot parse field [0] in \"map-colection\"");
}


// Get the pane's ID from file - this is the Minecraft map id for that map
Short id = null;
try {
id = Short.parseShort(split[1]);
}
catch(Exception ex) {
throw new SketchMapFileException("Unable to load SketchMap file \"" + file.getName()
+ "\" cannot parse field in \"map-colection\"");
+ "\" cannot parse field [1] in \"map-colection\"");
}

// Save id and location
mapCollection.put(id, loc);
}

// Get base format (png, jpg)
BaseFormat format = null;
try {
format = BaseFormat.valueOf(config.getString("base-format"));
Expand All @@ -156,6 +167,7 @@ public static SketchMap loadSketchMapFromFile(File file) throws SketchMapFileExc
+ "\" cannot parse BaseFormat from field \"base-format\"");
}

// Get the image in base64 string format, then decode to image
String b64Img = config.getString("map-image");
if(b64Img == null) {
throw new SketchMapFileException("Unable to load SketchMap file \"" + file.getName()
Expand All @@ -172,13 +184,16 @@ public static SketchMap loadSketchMapFromFile(File file) throws SketchMapFileExc
+ "\" parse image from field \"map-image\"");
}

// Get the first part of the filename to use as imageID (its name)
String imageID = file.getName().substring(0, file.getName().lastIndexOf("."));
if(getMapByID(imageID) != null) {
throw new SketchMapFileException("Unable to load SketchMap file \"" + file.getName()
+ "\" A SketchMap by that ID already exists.");
}

return new SketchMap(image, imageID, yPanes, yPanes, publicProtected, format);
// Create the SketchMap - there was a bug here, 'yPanes, yPanes' instead of 'xPanes, yPanes'
// - AND it was missing the mapCollection parameter at the end, which caused to to use the wrong map creation method
return new SketchMap(image, imageID, xPanes, yPanes, publicProtected, format, mapCollection);
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mcplugindev.slipswhitley.sketchmap;
package io.github.ebaldino.SketchMap;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

import com.mcplugindev.slipswhitley.sketchmap.command.SketchMapCommand;
import com.mcplugindev.slipswhitley.sketchmap.file.SketchMapLoader;
import com.mcplugindev.slipswhitley.sketchmap.listener.PlayerListener;
import io.github.ebaldino.SketchMap.command.SketchMapCommand;
import io.github.ebaldino.SketchMap.file.SketchMapLoader;
import io.github.ebaldino.SketchMap.listener.PlayerListener;

public class SketchMapPlugin extends JavaPlugin {

Expand Down
Loading