mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Rename stuff. Names are hard.
This commit is contained in:
parent
207cb04dbc
commit
48e14a1765
5 changed files with 47 additions and 42 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -37,7 +37,7 @@ Mage.Server/db
|
||||||
Mage.Server/cache
|
Mage.Server/cache
|
||||||
Mage.Server/mageserver.log
|
Mage.Server/mageserver.log
|
||||||
Mage.Server/magediag.log
|
Mage.Server/magediag.log
|
||||||
Mage.Server/customSets
|
Mage.Server/extensions
|
||||||
Mage.Sets/target
|
Mage.Sets/target
|
||||||
Mage.Stats/server.log
|
Mage.Stats/server.log
|
||||||
Mage.Stats/mageserver.log
|
Mage.Stats/mageserver.log
|
||||||
|
|
|
@ -36,10 +36,10 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point for external packages containing custom sets.
|
* Main entry point for external packages.
|
||||||
* @author Lymia
|
* @author Lymia
|
||||||
*/
|
*/
|
||||||
public abstract class CustomSetPackage {
|
public abstract class ExtensionPackage {
|
||||||
protected List<ExpansionSet> expansions = new ArrayList<>();
|
protected List<ExpansionSet> expansions = new ArrayList<>();
|
||||||
protected Map<String, Class> deckTypes = new HashMap<>();
|
protected Map<String, Class> deckTypes = new HashMap<>();
|
||||||
protected Map<String, Class> draftCubes = new HashMap<>();
|
protected Map<String, Class> draftCubes = new HashMap<>();
|
|
@ -37,8 +37,8 @@ import java.util.Scanner;
|
||||||
/**
|
/**
|
||||||
* @author Lymia
|
* @author Lymia
|
||||||
*/
|
*/
|
||||||
public class CustomSetLoader {
|
public class ExtensionPackageLoader {
|
||||||
public static CustomSetPackage loadCustomSet(File directory) throws IOException {
|
public static ExtensionPackage loadExtension(File directory) throws IOException {
|
||||||
if(!directory.exists ()) throw new RuntimeException("File not found "+directory);
|
if(!directory.exists ()) throw new RuntimeException("File not found "+directory);
|
||||||
if(!directory.isDirectory()) throw new RuntimeException(directory+" is not a directory");
|
if(!directory.isDirectory()) throw new RuntimeException(directory+" is not a directory");
|
||||||
|
|
||||||
|
@ -58,13 +58,13 @@ public class CustomSetLoader {
|
||||||
for(File f : packagesDirectory.listFiles()) classLoader.addURL(f.toURI().toURL());
|
for(File f : packagesDirectory.listFiles()) classLoader.addURL(f.toURI().toURL());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return (CustomSetPackage) Class.forName(entryPoint, false, classLoader).newInstance();
|
return (ExtensionPackage) Class.forName(entryPoint, false, classLoader).newInstance();
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException("Entry point class not found!", e);
|
throw new RuntimeException("Entry point class not found!", e);
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new RuntimeException("Entry point not an instance of CustomSetPackage.", e);
|
throw new RuntimeException("Entry point not an instance of ExtensionPackage.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -91,7 +91,7 @@ public class Main {
|
||||||
private static final String adminPasswordArg = "-adminPassword=";
|
private static final String adminPasswordArg = "-adminPassword=";
|
||||||
|
|
||||||
private static final File pluginFolder = new File("plugins");
|
private static final File pluginFolder = new File("plugins");
|
||||||
private static final File customSetsFolder = new File("customSets");
|
private static final File extensionFolder = new File("extensions");
|
||||||
|
|
||||||
public static PluginClassLoader classLoader = new PluginClassLoader();
|
public static PluginClassLoader classLoader = new PluginClassLoader();
|
||||||
public static TransporterServer server;
|
public static TransporterServer server;
|
||||||
|
@ -118,23 +118,23 @@ public class Main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Loading custom set packages...");
|
logger.info("Loading extension packages...");
|
||||||
List<CustomSetPackage> customSets = new ArrayList<>();
|
List<ExtensionPackage> extensions = new ArrayList<>();
|
||||||
if(!customSetsFolder.exists()) if(!customSetsFolder.mkdirs())
|
if(!extensionFolder.exists()) if(!extensionFolder.mkdirs())
|
||||||
logger.error("Could not create custom sets directory.");
|
logger.error("Could not create extensions directory.");
|
||||||
File[] customSetDirectories = customSetsFolder.listFiles();
|
File[] extensionDirectories = extensionFolder.listFiles();
|
||||||
if(customSetDirectories != null) for(File f : customSetDirectories) if(f.isDirectory())
|
if(extensionDirectories != null) for(File f : extensionDirectories) if(f.isDirectory())
|
||||||
try {
|
try {
|
||||||
logger.info(" - Loading custom set module from "+f);
|
logger.info(" - Loading extension from "+f);
|
||||||
customSets.add(CustomSetLoader.loadCustomSet(f));
|
extensions.add(ExtensionPackageLoader.loadExtension(f));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Could not load custom package in "+f+"!", e);
|
logger.error("Could not load extension in "+f+"!", e);
|
||||||
}
|
}
|
||||||
logger.info("Done.");
|
logger.info("Done.");
|
||||||
|
|
||||||
if(!customSets.isEmpty()) {
|
if(!extensions.isEmpty()) {
|
||||||
logger.info("Registering custom sets...");
|
logger.info("Registering custom sets...");
|
||||||
for(CustomSetPackage pkg : customSets) {
|
for(ExtensionPackage pkg : extensions) {
|
||||||
for(ExpansionSet set : pkg.getSets()) {
|
for(ExpansionSet set : pkg.getSets()) {
|
||||||
logger.info("- Loading "+set.getName()+" ("+set.getCode()+")");
|
logger.info("- Loading "+set.getName()+" ("+set.getCode()+")");
|
||||||
Sets.getInstance().addSet(set);
|
Sets.getInstance().addSet(set);
|
||||||
|
@ -174,14 +174,17 @@ public class Main {
|
||||||
DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CustomSetPackage pkg : customSets) {
|
for (ExtensionPackage pkg : extensions) {
|
||||||
Map<String, Class> draftCubes = pkg.getDraftCubes();
|
Map<String, Class> draftCubes = pkg.getDraftCubes();
|
||||||
for (String name : draftCubes.keySet())
|
for (String name : draftCubes.keySet()) {
|
||||||
|
logger.info("Loading extension: ["+name+"] "+draftCubes.get(name).toString());
|
||||||
CubeFactory.getInstance().addDraftCube(name, draftCubes.get(name));
|
CubeFactory.getInstance().addDraftCube(name, draftCubes.get(name));
|
||||||
|
}
|
||||||
Map<String, Class> deckTypes = pkg.getDeckTypes();
|
Map<String, Class> deckTypes = pkg.getDeckTypes();
|
||||||
for (String name : deckTypes.keySet())
|
for (String name : deckTypes.keySet()) {
|
||||||
|
logger.info("Loading extension: ["+name+"] "+deckTypes.get(name));
|
||||||
DeckValidatorFactory.getInstance().addDeckType(name, deckTypes.get(name));
|
DeckValidatorFactory.getInstance().addDeckType(name, deckTypes.get(name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Config - max seconds idle: " + config.getMaxSecondsIdle());
|
logger.info("Config - max seconds idle: " + config.getMaxSecondsIdle());
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class GameEvent implements Serializable {
|
||||||
protected String data;
|
protected String data;
|
||||||
protected Zone zone;
|
protected Zone zone;
|
||||||
protected ArrayList<UUID> appliedEffects = new ArrayList<>();
|
protected ArrayList<UUID> appliedEffects = new ArrayList<>();
|
||||||
protected UUID pluginEventType = null;
|
protected UUID customEventType = null;
|
||||||
|
|
||||||
public enum EventType {
|
public enum EventType {
|
||||||
|
|
||||||
|
@ -272,13 +272,13 @@ public class GameEvent implements Serializable {
|
||||||
COMBAT_DAMAGE_APPLIED,
|
COMBAT_DAMAGE_APPLIED,
|
||||||
SELECTED_ATTACKER, SELECTED_BLOCKER,
|
SELECTED_ATTACKER, SELECTED_BLOCKER,
|
||||||
//custom events
|
//custom events
|
||||||
PLUGIN_EVENT;
|
CUSTOM_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameEvent(EventType type, UUID pluginEventType,
|
private GameEvent(EventType type, UUID customEventType,
|
||||||
UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.pluginEventType = pluginEventType;
|
this.customEventType = customEventType;
|
||||||
this.targetId = targetId;
|
this.targetId = targetId;
|
||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
|
@ -294,12 +294,12 @@ public class GameEvent implements Serializable {
|
||||||
this(type, null, targetId, sourceId, playerId, amount, flag);
|
this(type, null, targetId, sourceId, playerId, amount, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
public GameEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||||
this(EventType.PLUGIN_EVENT, pluginEventType, targetId, sourceId, playerId, 0, false);
|
this(EventType.CUSTOM_EVENT, customEventType, targetId, sourceId, playerId, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
public GameEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
||||||
this(EventType.PLUGIN_EVENT, pluginEventType, targetId, sourceId, playerId, amount, flag);
|
this(EventType.CUSTOM_EVENT, customEventType, targetId, sourceId, playerId, amount, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameEvent getEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
public static GameEvent getEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
||||||
|
@ -321,20 +321,20 @@ public class GameEvent implements Serializable {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
||||||
return new GameEvent(pluginEventType, targetId, sourceId, playerId, amount, false);
|
return new GameEvent(customEventType, targetId, sourceId, playerId, amount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||||
return new GameEvent(pluginEventType, targetId, sourceId, playerId);
|
return new GameEvent(customEventType, targetId, sourceId, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID playerId) {
|
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID playerId) {
|
||||||
return new GameEvent(pluginEventType, targetId, null, playerId);
|
return new GameEvent(customEventType, targetId, null, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID playerId, String data, int amount) {
|
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID playerId, String data, int amount) {
|
||||||
GameEvent event = getEvent(pluginEventType, targetId, playerId);
|
GameEvent event = getEvent(customEventType, targetId, playerId);
|
||||||
event.setAmount(amount);
|
event.setAmount(amount);
|
||||||
event.setData(data);
|
event.setData(data);
|
||||||
return event;
|
return event;
|
||||||
|
@ -344,7 +344,9 @@ public class GameEvent implements Serializable {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getPluginEventType() { return pluginEventType; }
|
public UUID getCustomEventType() {
|
||||||
|
return customEventType;
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getTargetId() {
|
public UUID getTargetId() {
|
||||||
return targetId;
|
return targetId;
|
||||||
|
@ -412,8 +414,8 @@ public class GameEvent implements Serializable {
|
||||||
return appliedEffects;
|
return appliedEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPluginEvent(UUID pluginEventType) {
|
public boolean isCustomEvent(UUID customEventType) {
|
||||||
return type == EventType.PLUGIN_EVENT && this.pluginEventType.equals(pluginEventType);
|
return type == EventType.CUSTOM_EVENT && this.customEventType.equals(customEventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAppliedEffects(ArrayList<UUID> appliedEffects) {
|
public void setAppliedEffects(ArrayList<UUID> appliedEffects) {
|
||||||
|
|
Loading…
Reference in a new issue