Merge pull request #33 from TBMCPlugins/dev
Added check for Maven project in updater and getTypeForFolder for the user class
This commit is contained in:
commit
6a2113bda4
4 changed files with 28 additions and 3 deletions
|
@ -1 +1,3 @@
|
||||||
language: java
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk8
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.chat.CommandClass;
|
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,16 @@ public class TBMCCoreAPI {
|
||||||
error(sender, "Can't find branch \"" + branch + "\" for plugin \"" + correctname + "\"");
|
error(sender, "Can't find branch \"" + branch + "\" for plugin \"" + correctname + "\"");
|
||||||
return false;
|
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());
|
info(sender, "Updating TBMC plugin: " + correctname + " from " + correctbranch.get());
|
||||||
URL url;
|
URL url;
|
||||||
final boolean isWindows = System.getProperty("os.name").contains("Windows");
|
final boolean isWindows = System.getProperty("os.name").contains("Windows");
|
||||||
|
|
|
@ -7,13 +7,16 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
|
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
|
||||||
@ChromaGamerEnforcer
|
@ChromaGamerEnforcer
|
||||||
public abstract class ChromaGamerBase implements AutoCloseable {
|
public abstract class ChromaGamerBase implements AutoCloseable {
|
||||||
public static final String TBMC_PLAYERS_DIR = "TBMC/players/";
|
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)})
|
* 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.
|
* Returns the folder name for the given player class.
|
||||||
*
|
*
|
||||||
* @param cl
|
* @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
|
* @return The folder name for the given type
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* If the class doesn't have the {@link UserClass} annotation.
|
* 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");
|
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>
|
* 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>
|
* <b>Does not include .yml</b>
|
||||||
|
|
Loading…
Reference in a new issue