mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Remove /mmoupdate and replace with /mcconvert database
This commit is contained in:
parent
8282d84b16
commit
ede0757d83
@ -35,6 +35,7 @@ Version 1.4.07-dev
|
||||
! Updated localization files
|
||||
! Party item share category states are now saved when the server shuts down.
|
||||
! When using Super Breaker or Giga Driller abilities extra tool durability is used (again)
|
||||
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
|
||||
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
|
||||
|
||||
Version 1.4.06
|
||||
|
@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
|
||||
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
|
||||
|
||||
if ((newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1])) || previousType == newType) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType);
|
||||
|
||||
if (previousType == DatabaseType.CUSTOM) {
|
||||
Class<?> clazz;
|
||||
|
||||
try {
|
||||
clazz = Class.forName(args[1]);
|
||||
|
||||
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
sender.sendMessage("An error occurred during the conversion process."); // TODO: Localize
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
|
||||
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getName(), false);
|
||||
|
||||
if (profile.isLoaded()) {
|
||||
mcMMO.getDatabaseManager().saveUser(profile);
|
||||
}
|
||||
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,71 +5,67 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McconvertCommand implements TabExecutor {
|
||||
private static final List<String> FORMULA_TYPES;
|
||||
private static final List<String> DATABASE_TYPES;
|
||||
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
|
||||
|
||||
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
|
||||
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
ArrayList<String> formulaTypes = new ArrayList<String>();
|
||||
|
||||
for (FormulaType type : FormulaType.values()) {
|
||||
types.add(type.toString());
|
||||
formulaTypes.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
FORMULA_TYPES = ImmutableList.copyOf(types);
|
||||
Collections.sort(formulaTypes);
|
||||
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
|
||||
}
|
||||
|
||||
static {
|
||||
ArrayList<String> databaseTypes = new ArrayList<String>();
|
||||
|
||||
for (DatabaseType type : DatabaseType.values()) {
|
||||
databaseTypes.add(type.toString());
|
||||
}
|
||||
|
||||
// Custom stuff
|
||||
databaseTypes.remove(DatabaseType.CUSTOM);
|
||||
|
||||
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
|
||||
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
|
||||
}
|
||||
|
||||
Collections.sort(databaseTypes);
|
||||
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do this later; Use mcconvert instead of mmoupdate:
|
||||
* OLD :
|
||||
* /mmoupdate flatfile / mysql
|
||||
*
|
||||
* NEW :
|
||||
* /mcconvert <database> <flatfile / sql>
|
||||
* /mcconvert <experience> <linear / exponential>
|
||||
* */
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
|
||||
FormulaType newType = FormulaType.getFormulaType(args[0].toUpperCase());
|
||||
|
||||
if (newType == FormulaType.UNKNOWN) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Invalid"));
|
||||
return true;
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
|
||||
return databaseConvertCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
|
||||
return experienceConvertCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (previousType == newType) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Same", newType));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Start", previousType.toString(), newType.toString()));
|
||||
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
|
||||
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -79,7 +75,16 @@ public class McconvertCommand implements TabExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size()));
|
||||
return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<String>(SUBCOMMANDS.size()));
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
|
||||
StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<String>(DATABASE_TYPES.size()));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) {
|
||||
StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size()));
|
||||
}
|
||||
|
||||
return ImmutableList.of();
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
@ -1,133 +0,0 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.database.ConversionTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MmoupdateCommand implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
String argType = args[0];
|
||||
String oldType = validateName(sender, args[0]);
|
||||
if (oldType == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String newType = getCurrentDb();
|
||||
|
||||
if (newType.equals(oldType)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Same", argType));
|
||||
return true;
|
||||
}
|
||||
|
||||
DatabaseManager oldDb;
|
||||
if (oldType.equals("sql")) {
|
||||
oldDb = DatabaseManagerFactory.createSQLDatabaseManager();
|
||||
}
|
||||
else if (oldType.equals("flatfile")) {
|
||||
oldDb = DatabaseManagerFactory.createFlatfileDatabaseManager();
|
||||
}
|
||||
else try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends DatabaseManager> clazz = (Class<? extends DatabaseManager>) Class.forName(oldType);
|
||||
oldDb = DatabaseManagerFactory.createCustomDatabaseManager(clazz);
|
||||
|
||||
oldType = clazz.getSimpleName(); // For pretty-printing; we have the database now
|
||||
}
|
||||
catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start", oldType, newType));
|
||||
|
||||
// Convert the online players right away, without waiting
|
||||
// first, flush out the current data
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
// Get the profile from the old database and save it in the new
|
||||
PlayerProfile profile = oldDb.loadPlayerProfile(player.getName(), false);
|
||||
if (profile.isLoaded()) {
|
||||
mcMMO.getDatabaseManager().saveUser(profile);
|
||||
}
|
||||
|
||||
// Reload from the current database via UserManager
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
// Schedule the task for all users
|
||||
new ConversionTask(oldDb, sender, oldType, newType).runTaskAsynchronously(mcMMO.p);
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null - if type not recognized / class not found
|
||||
* empty string - if type is same as current
|
||||
* normalized string - if type is recognized
|
||||
*/
|
||||
private String validateName(CommandSender sender, String type) {
|
||||
if (type.equalsIgnoreCase("sql") || type.equalsIgnoreCase("mysql")) {
|
||||
return "sql";
|
||||
}
|
||||
|
||||
if (type.equalsIgnoreCase("flatfile") || type.equalsIgnoreCase("file")) {
|
||||
return "flatfile";
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> clazz = Class.forName(type);
|
||||
|
||||
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.InvalidType", type));
|
||||
return null;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
catch (Exception e) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.InvalidType", type));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentDb() {
|
||||
if (DatabaseManagerFactory.getCustomDatabaseManagerClass() != null) {
|
||||
return DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName();
|
||||
}
|
||||
|
||||
return Config.getInstance().getUseMySQL() ? "sql" : "flatfile";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
|
||||
if (clazz != null) {
|
||||
return ImmutableList.of("flatfile", "sql", clazz.getName());
|
||||
}
|
||||
return ImmutableList.of("flatfile", "sql");
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class ConvertExperienceCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
|
||||
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase());
|
||||
|
||||
if (newType == FormulaType.UNKNOWN) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (previousType == newType) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
|
||||
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
|
||||
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
|
||||
@ -86,4 +87,11 @@ public interface DatabaseManager {
|
||||
* @param destination The DatabaseManager to save to
|
||||
*/
|
||||
public void convertUsers(DatabaseManager destination);
|
||||
|
||||
/**
|
||||
* Retrieve the type of database in use. Custom databases should return CUSTOM.
|
||||
*
|
||||
* @return The type of database
|
||||
*/
|
||||
public DatabaseType getDatabaseType();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.database;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
|
||||
public class DatabaseManagerFactory {
|
||||
private static Class<? extends DatabaseManager> customManager = null;
|
||||
@ -10,20 +11,23 @@ public class DatabaseManagerFactory {
|
||||
if (customManager != null) {
|
||||
try {
|
||||
return createCustomDatabaseManager(customManager);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.debug("Could not create custom database manager");
|
||||
e.printStackTrace();
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
mcMMO.p.debug("Failed to create custom database manager");
|
||||
e.printStackTrace();
|
||||
}
|
||||
mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
||||
}
|
||||
|
||||
return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatfileDatabaseManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the custom DatabaseManager class for McMMO to use. This should be
|
||||
* Sets the custom DatabaseManager class for mcMMO to use. This should be
|
||||
* called prior to mcMMO enabling.
|
||||
* <p>
|
||||
* The provided class must have an empty constructor, which is the one
|
||||
@ -41,7 +45,8 @@ public class DatabaseManagerFactory {
|
||||
try {
|
||||
clazz.getConstructor((Class<?>) null);
|
||||
customManager = clazz;
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw new IllegalArgumentException("Provided database manager class must have an empty constructor", e);
|
||||
}
|
||||
}
|
||||
@ -50,16 +55,20 @@ public class DatabaseManagerFactory {
|
||||
return customManager;
|
||||
}
|
||||
|
||||
// For data conversion purposes
|
||||
|
||||
public static FlatfileDatabaseManager createFlatfileDatabaseManager() {
|
||||
public static DatabaseManager createDatabaseManager(DatabaseType type) {
|
||||
switch (type) {
|
||||
case FLATFILE:
|
||||
return new FlatfileDatabaseManager();
|
||||
}
|
||||
|
||||
public static SQLDatabaseManager createSQLDatabaseManager() {
|
||||
case SQL:
|
||||
return new SQLDatabaseManager();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Why is clazz never used here?
|
||||
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
||||
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
@ -793,4 +794,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
return skills;
|
||||
}
|
||||
|
||||
public DatabaseType getDatabaseType() {
|
||||
return DatabaseType.FLATFILE;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import java.util.logging.Level;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseUpdateType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
@ -1191,4 +1192,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
|
||||
public DatabaseType getDatabaseType() {
|
||||
return DatabaseType.SQL;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.datatypes.database;
|
||||
|
||||
public enum DatabaseType {
|
||||
FLATFILE,
|
||||
SQL,
|
||||
CUSTOM;
|
||||
|
||||
public static DatabaseType getDatabaseType(String typeName) {
|
||||
for (DatabaseType type : values()) {
|
||||
if (type.name().equalsIgnoreCase(typeName)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeName.equalsIgnoreCase("file")) {
|
||||
return FLATFILE;
|
||||
}
|
||||
else if (typeName.equalsIgnoreCase("mysql")) {
|
||||
return SQL;
|
||||
}
|
||||
|
||||
return CUSTOM;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class ConversionTask extends BukkitRunnable {
|
||||
private final DatabaseManager sourceDb;
|
||||
private final CommandSender sender;
|
||||
private final String message;
|
||||
|
||||
public ConversionTask(DatabaseManager from, CommandSender sendback, String oldType, String newType) {
|
||||
sourceDb = from;
|
||||
sender = sendback;
|
||||
message = LocaleLoader.getString("Commands.mmoupdate.Finish", oldType, newType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sourceDb.convertUsers(mcMMO.getDatabaseManager());
|
||||
|
||||
// Announce completeness
|
||||
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new CompleteAnnouncement());
|
||||
}
|
||||
|
||||
public class CompleteAnnouncement implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sender.sendMessage(message);
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().log(Level.WARNING, "Exception sending database conversion completion message to " + sender.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class DatabaseConversionTask extends BukkitRunnable {
|
||||
private final DatabaseManager sourceDatabase;
|
||||
private final CommandSender sender;
|
||||
private final String message;
|
||||
|
||||
public DatabaseConversionTask(DatabaseManager sourceDatabase, CommandSender sender, String oldType, String newType) {
|
||||
this.sourceDatabase = sourceDatabase;
|
||||
this.sender = sender;
|
||||
message = LocaleLoader.getString("Commands.mcconvert.Database.Finish", oldType, newType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sourceDatabase.convertUsers(mcMMO.getDatabaseManager());
|
||||
|
||||
mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ public class FormulaConversionTask extends BukkitRunnable {
|
||||
}
|
||||
mcMMO.getFormulaManager().setPreviousFormulaType(formulaType);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Finish", formulaType.toString()));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", formulaType.toString()));
|
||||
}
|
||||
|
||||
private void editValues(PlayerProfile profile) {
|
||||
|
@ -20,7 +20,6 @@ import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.database.McpurgeCommand;
|
||||
import com.gmail.nossr50.commands.database.McremoveCommand;
|
||||
import com.gmail.nossr50.commands.database.MmoshowdbCommand;
|
||||
import com.gmail.nossr50.commands.database.MmoupdateCommand;
|
||||
import com.gmail.nossr50.commands.database.McconvertCommand;
|
||||
import com.gmail.nossr50.commands.experience.AddlevelsCommand;
|
||||
import com.gmail.nossr50.commands.experience.AddxpCommand;
|
||||
@ -274,14 +273,14 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new McremoveCommand());
|
||||
}
|
||||
|
||||
private static void registerMmoupdateCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mmoupdate");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
|
||||
command.setPermission("mcmmo.commands.mmoupdate");
|
||||
command.setPermissionMessage(LocaleLoader.getString("Commands.mmoupdate.OpOnly"));
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mmoupdate", "<confirm|flatfile|sql|" + LocaleLoader.getString("Commands.Usage.FullClassName") + ">"));
|
||||
command.setExecutor(new MmoupdateCommand());
|
||||
}
|
||||
// private static void registerMmoupdateCommand() {
|
||||
// PluginCommand command = mcMMO.p.getCommand("mmoupdate");
|
||||
// command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
|
||||
// command.setPermission("mcmmo.commands.mmoupdate");
|
||||
// command.setPermissionMessage(LocaleLoader.getString("Commands.mmoupdate.OpOnly"));
|
||||
// command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mmoupdate", "<flatfile|sql|" + LocaleLoader.getString("Commands.Usage.FullClassName") + ">"));
|
||||
// command.setExecutor(new MmoupdateCommand());
|
||||
// }
|
||||
|
||||
private static void registerMmoshowdbCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mmoshowdb");
|
||||
@ -295,9 +294,9 @@ public final class CommandRegistrationManager {
|
||||
private static void registerMcconvertCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcconvert");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcconvert"));
|
||||
command.setPermission("mcmmo.commands.mcconvert");
|
||||
command.setPermission("mcmmo.commands.mcconvert;mcmmo.commands.mcconvert.experience;mcmmo.commands.mcconvert.database");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcconvert", "<linear | exponential>"));
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mcconvert", "<database|experience>", "<linear|exponential>"));
|
||||
command.setExecutor(new McconvertCommand());
|
||||
}
|
||||
|
||||
@ -440,7 +439,6 @@ public final class CommandRegistrationManager {
|
||||
// Database Commands
|
||||
registerMcpurgeCommand();
|
||||
registerMcremoveCommand();
|
||||
registerMmoupdateCommand();
|
||||
registerMmoshowdbCommand();
|
||||
registerMcconvertCommand();
|
||||
|
||||
|
@ -442,15 +442,15 @@ Commands.mmoedit=[player] <skill> <newvalue> [[RED]] - Modify target
|
||||
Commands.mmoedit.AllSkills.1=[[GREEN]]Your level in all skills was set to {0}!
|
||||
Commands.mmoedit.Modified.1=[[GREEN]]Your level in {0} was set to {1}!
|
||||
Commands.mmoedit.Modified.2=[[RED]]{0} has been modified for {1}.
|
||||
Commands.mmoupdate.Same=[[RED]]You are already using the {0} database!
|
||||
Commands.mmoupdate.InvalidType=[[RED]]{0} is not a valid database type.
|
||||
Commands.mmoupdate.Start=[[GRAY]]Starting conversion from {0} to {1}...
|
||||
Commands.mmoupdate.Finish=[[GRAY]]Database migration complete; the {1} database now has all data from the {0} database.
|
||||
Commands.mcconvert.Database.Same=[[RED]]You are already using the {0} database!
|
||||
Commands.mcconvert.Database.InvalidType=[[RED]]{0} is not a valid database type.
|
||||
Commands.mcconvert.Database.Start=[[GRAY]]Starting conversion from {0} to {1}...
|
||||
Commands.mcconvert.Database.Finish=[[GRAY]]Database migration complete; the {1} database now has all data from the {0} database.
|
||||
Commands.mmoshowdb=[[YELLOW]]The currently used database is [[GREEN]]{0}
|
||||
Commands.mcconvert.Invalid=[[RED]]Unknown formula type! Valid types are: [[GREEN]]LINEAR [[RED]]and [[GREEN]]EXPONENTIAL.
|
||||
Commands.mcconvert.Same=[[RED]]Already using formula type {0}
|
||||
Commands.mcconvert.Start=[[GRAY]]Starting conversion from {0} to {1} curve
|
||||
Commands.mcconvert.Finish=[[GRAY]]Formula conversion complete; now using an {0} XP curve.
|
||||
Commands.mcconvert.Experience.Invalid=[[RED]]Unknown formula type! Valid types are: [[GREEN]]LINEAR [[RED]]and [[GREEN]]EXPONENTIAL.
|
||||
Commands.mcconvert.Experience.Same=[[RED]]Already using formula type {0}
|
||||
Commands.mcconvert.Experience.Start=[[GRAY]]Starting conversion from {0} to {1} curve
|
||||
Commands.mcconvert.Experience.Finish=[[GRAY]]Formula conversion complete; now using {0} XP curve.
|
||||
Commands.ModDescription=[[RED]]- Read brief mod description
|
||||
Commands.NoConsole=This command does not support console usage.
|
||||
Commands.Notifications.Off=Ability notifications toggled [[RED]]off
|
||||
@ -759,7 +759,7 @@ Commands.Description.mcstats=Show your mcMMO levels and XP
|
||||
Commands.Description.mctop=Show mcMMO leader boards
|
||||
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
||||
Commands.Description.mmoupdate=Migrate mcMMO database from an old database into the current one
|
||||
Commands.Description.mcconvert=Converts formula types
|
||||
Commands.Description.mcconvert=Converts database types or experience formula types
|
||||
Commands.Description.mmoshowdb=Show the name of the current database type (for later use with /mmoupdate)
|
||||
Commands.Description.party=Control various mcMMO party settings
|
||||
Commands.Description.partychat=Toggle mcMMO party chat on/off or send party chat messages
|
||||
|
@ -62,7 +62,7 @@ commands:
|
||||
mmoshowdb:
|
||||
description: Show the name of the current database type (for later use with /mmoupdate)
|
||||
mcconvert:
|
||||
description: Convert from linear to exponential formula
|
||||
description: Convert between different database and formula types
|
||||
partychat:
|
||||
aliases: [pc, p]
|
||||
description: Toggle Party chat or send party chat messages
|
||||
@ -601,6 +601,7 @@ permissions:
|
||||
default: false
|
||||
description: Implies access to everything in mcMMO
|
||||
children:
|
||||
mcmmo.commands.mcconvert.all: true
|
||||
mcmmo.commands.mmoupdate: true
|
||||
mcmmo.commands.xprate.all: true
|
||||
mcmmo.bypass.*:
|
||||
@ -664,9 +665,6 @@ permissions:
|
||||
children:
|
||||
mcmmo.commands.defaults: true
|
||||
mcmmo.commands.defaultsop: true
|
||||
mcmmo.commands.mcpurge: true
|
||||
mcmmo.commands.mcremove: true
|
||||
mcmmo.commands.mmoupdate: true
|
||||
mcmmo.commands.defaults:
|
||||
description: Implies all default mcmmo.commands permissions.
|
||||
children:
|
||||
@ -711,6 +709,7 @@ permissions:
|
||||
mcmmo.commands.kraken: true
|
||||
mcmmo.commands.kraken.others: true
|
||||
mcmmo.commands.mcability.others: true
|
||||
mcmmo.commands.mcconvert.all: true
|
||||
mcmmo.commands.mcgod: true
|
||||
mcmmo.commands.mcgod.others: true
|
||||
mcmmo.commands.mcpurge: true
|
||||
@ -720,7 +719,6 @@ permissions:
|
||||
mcmmo.commands.mcremove: true
|
||||
mcmmo.commands.mmoedit: true
|
||||
mcmmo.commands.mmoedit.others: true
|
||||
mcmmo.commands.mmoupdate: true
|
||||
mcmmo.commands.mmoshowdb: true
|
||||
mcmmo.commands.ptp.world.all: true
|
||||
mcmmo.commands.skillreset.all: true
|
||||
@ -802,6 +800,20 @@ permissions:
|
||||
description: Allows access to the mcmmo help command
|
||||
children:
|
||||
mcmmo.commands.mcmmo.help: true
|
||||
mcmmo.commands.mcconvert.*:
|
||||
default: false
|
||||
description: Allows access to the mcconvert commands
|
||||
children:
|
||||
mcmmo.commands.mcconvert.all: true
|
||||
mcmmo.commands.mcconvert.all:
|
||||
description: Allows access to the mcconvert commands
|
||||
children:
|
||||
mcmmo.commands.mcconvert.database: true
|
||||
mcmmo.commands.mcconvert.experience: true
|
||||
mcmmo.commands.mcconvert.database:
|
||||
description: Allows access to the mcconvert command for databases
|
||||
mcmmo.commands.mcconvert.experience:
|
||||
description: Allows access to the mcconvert command for experience
|
||||
mcmmo.commands.mcgod:
|
||||
description: Allows access to the mcgod command
|
||||
mcmmo.commands.mcgod.others:
|
||||
@ -912,11 +924,13 @@ permissions:
|
||||
mcmmo.commands.mmoedit.others:
|
||||
description: Allows access to the mmoedit command for other players
|
||||
mcmmo.commands.mmoupdate:
|
||||
default: false
|
||||
description: Allows access to the mmoupdate command
|
||||
children:
|
||||
mcmmo.commands.mcconvert.database: true
|
||||
mcmmo.commands.mmoshowdb:
|
||||
description: Allows access to the mmoshowdb command
|
||||
mcmmo.commands.mobhealth:
|
||||
default: true
|
||||
description: Allows access to the mobhealth command
|
||||
mcmmo.commands.party.*:
|
||||
default: false
|
||||
|
Loading…
Reference in New Issue
Block a user