Added check for Maven project in updater and getTypeForFolder for the user class #33

Merged
NorbiPeti merged 4 commits from dev into master 2017-06-19 07:17:00 +00:00
4 changed files with 28 additions and 3 deletions

View file

@ -1 +1,3 @@
language: java
jdk:
- oraclejdk8

View file

@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.CommandClass;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.chat.TBMCCommandBase;

View file

@ -81,6 +81,16 @@ public class TBMCCoreAPI {
error(sender, "Can't find branch \"" + branch + "\" for plugin \"" + correctname + "\"");
return false;
}
try {
if (DownloadString("https://raw.githubusercontent.com/TBMCPlugins/" + correctname + "/"
+ correctbranch.get() + "/pom.xml").equals("404: Not Found\n")) {
error(sender, "The plugin doesn't appear to have a pom.xml. Make sure it's a Maven project.");
return false;
}
} catch (IOException e1) {
error(sender, "The plugin doesn't appear to have a pom.xml. Make sure it's a Maven project.\n" + e1);
return false;
}
info(sender, "Updating TBMC plugin: " + correctname + " from " + correctbranch.get());
URL url;
final boolean isWindows = System.getProperty("os.name").contains("Windows");

View file

@ -7,13 +7,16 @@ import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import com.google.common.collect.HashBiMap;
import buttondevteam.lib.TBMCCoreAPI;
@ChromaGamerEnforcer
public abstract class ChromaGamerBase implements AutoCloseable {
public static final String TBMC_PLAYERS_DIR = "TBMC/players/";
private static final HashMap<Class<?>, String> playerTypes = new HashMap<>();
private static final HashBiMap<Class<?>, String> playerTypes = HashBiMap.create();
/**
* Used for connecting with every type of user ({@link #connectWith(ChromaGamerBase)})
@ -32,7 +35,7 @@ public abstract class ChromaGamerBase implements AutoCloseable {
* Returns the folder name for the given player class.
*
* @param cl
* The class to get the folder from (like {@link TBMCPlayerBase} or one of it's subclasses
* The class to get the folder from (like {@link TBMCPlayerBase} or one of it's subclasses)
* @return The folder name for the given type
* @throws RuntimeException
* If the class doesn't have the {@link UserClass} annotation.
@ -45,6 +48,17 @@ public abstract class ChromaGamerBase implements AutoCloseable {
throw new RuntimeException("Class not registered as a user class! Use @UserClass or @AbstractUserClass");
}
/**
* Returns the player class for the given folder name.
*
* @param foldername
* The folder to get the class from (like "minecraft")
* @return The type for the given folder name or null if not found
*/
public static Class<?> getTypeForFolder(String foldername) {
return playerTypes.inverse().get(foldername);
}
/**
* This method returns the filename for this player data. For example, for Minecraft-related data, MC UUIDs, for Discord data, use Discord IDs, etc.<br>
* <b>Does not include .yml</b>