mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +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/mageserver.log
|
||||
Mage.Server/magediag.log
|
||||
Mage.Server/customSets
|
||||
Mage.Server/extensions
|
||||
Mage.Sets/target
|
||||
Mage.Stats/server.log
|
||||
Mage.Stats/mageserver.log
|
||||
|
|
|
@ -36,10 +36,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Main entry point for external packages containing custom sets.
|
||||
* Main entry point for external packages.
|
||||
* @author Lymia
|
||||
*/
|
||||
public abstract class CustomSetPackage {
|
||||
public abstract class ExtensionPackage {
|
||||
protected List<ExpansionSet> expansions = new ArrayList<>();
|
||||
protected Map<String, Class> deckTypes = new HashMap<>();
|
||||
protected Map<String, Class> draftCubes = new HashMap<>();
|
|
@ -37,8 +37,8 @@ import java.util.Scanner;
|
|||
/**
|
||||
* @author Lymia
|
||||
*/
|
||||
public class CustomSetLoader {
|
||||
public static CustomSetPackage loadCustomSet(File directory) throws IOException {
|
||||
public class ExtensionPackageLoader {
|
||||
public static ExtensionPackage loadExtension(File directory) throws IOException {
|
||||
if(!directory.exists ()) throw new RuntimeException("File not found "+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());
|
||||
|
||||
try {
|
||||
return (CustomSetPackage) Class.forName(entryPoint, false, classLoader).newInstance();
|
||||
return (ExtensionPackage) Class.forName(entryPoint, false, classLoader).newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Entry point class not found!", 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 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 TransporterServer server;
|
||||
|
@ -118,23 +118,23 @@ public class Main {
|
|||
}
|
||||
}
|
||||
|
||||
logger.info("Loading custom set packages...");
|
||||
List<CustomSetPackage> customSets = new ArrayList<>();
|
||||
if(!customSetsFolder.exists()) if(!customSetsFolder.mkdirs())
|
||||
logger.error("Could not create custom sets directory.");
|
||||
File[] customSetDirectories = customSetsFolder.listFiles();
|
||||
if(customSetDirectories != null) for(File f : customSetDirectories) if(f.isDirectory())
|
||||
logger.info("Loading extension packages...");
|
||||
List<ExtensionPackage> extensions = new ArrayList<>();
|
||||
if(!extensionFolder.exists()) if(!extensionFolder.mkdirs())
|
||||
logger.error("Could not create extensions directory.");
|
||||
File[] extensionDirectories = extensionFolder.listFiles();
|
||||
if(extensionDirectories != null) for(File f : extensionDirectories) if(f.isDirectory())
|
||||
try {
|
||||
logger.info(" - Loading custom set module from "+f);
|
||||
customSets.add(CustomSetLoader.loadCustomSet(f));
|
||||
logger.info(" - Loading extension from "+f);
|
||||
extensions.add(ExtensionPackageLoader.loadExtension(f));
|
||||
} 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.");
|
||||
|
||||
if(!customSets.isEmpty()) {
|
||||
if(!extensions.isEmpty()) {
|
||||
logger.info("Registering custom sets...");
|
||||
for(CustomSetPackage pkg : customSets) {
|
||||
for(ExtensionPackage pkg : extensions) {
|
||||
for(ExpansionSet set : pkg.getSets()) {
|
||||
logger.info("- Loading "+set.getName()+" ("+set.getCode()+")");
|
||||
Sets.getInstance().addSet(set);
|
||||
|
@ -174,15 +174,18 @@ public class Main {
|
|||
DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
|
||||
for (CustomSetPackage pkg : customSets) {
|
||||
for (ExtensionPackage pkg : extensions) {
|
||||
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));
|
||||
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Config - max seconds idle: " + config.getMaxSecondsIdle());
|
||||
logger.info("Config - max game threads: " + config.getMaxGameThreads());
|
||||
|
|
|
@ -47,7 +47,7 @@ public class GameEvent implements Serializable {
|
|||
protected String data;
|
||||
protected Zone zone;
|
||||
protected ArrayList<UUID> appliedEffects = new ArrayList<>();
|
||||
protected UUID pluginEventType = null;
|
||||
protected UUID customEventType = null;
|
||||
|
||||
public enum EventType {
|
||||
|
||||
|
@ -272,13 +272,13 @@ public class GameEvent implements Serializable {
|
|||
COMBAT_DAMAGE_APPLIED,
|
||||
SELECTED_ATTACKER, SELECTED_BLOCKER,
|
||||
//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) {
|
||||
this.type = type;
|
||||
this.pluginEventType = pluginEventType;
|
||||
this.customEventType = customEventType;
|
||||
this.targetId = targetId;
|
||||
this.sourceId = sourceId;
|
||||
this.amount = amount;
|
||||
|
@ -294,12 +294,12 @@ public class GameEvent implements Serializable {
|
|||
this(type, null, targetId, sourceId, playerId, amount, flag);
|
||||
}
|
||||
|
||||
public GameEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
this(EventType.PLUGIN_EVENT, pluginEventType, targetId, sourceId, playerId, 0, false);
|
||||
public GameEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
this(EventType.CUSTOM_EVENT, customEventType, targetId, sourceId, playerId, 0, false);
|
||||
}
|
||||
|
||||
public GameEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
||||
this(EventType.PLUGIN_EVENT, pluginEventType, targetId, sourceId, playerId, amount, flag);
|
||||
public GameEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean 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) {
|
||||
|
@ -321,20 +321,20 @@ public class GameEvent implements Serializable {
|
|||
return event;
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
||||
return new GameEvent(pluginEventType, targetId, sourceId, playerId, amount, false);
|
||||
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
||||
return new GameEvent(customEventType, targetId, sourceId, playerId, amount, false);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
return new GameEvent(pluginEventType, targetId, sourceId, playerId);
|
||||
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
return new GameEvent(customEventType, targetId, sourceId, playerId);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID playerId) {
|
||||
return new GameEvent(pluginEventType, targetId, null, playerId);
|
||||
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID playerId) {
|
||||
return new GameEvent(customEventType, targetId, null, playerId);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID playerId, String data, int amount) {
|
||||
GameEvent event = getEvent(pluginEventType, targetId, playerId);
|
||||
public static GameEvent getEvent(UUID customEventType, UUID targetId, UUID playerId, String data, int amount) {
|
||||
GameEvent event = getEvent(customEventType, targetId, playerId);
|
||||
event.setAmount(amount);
|
||||
event.setData(data);
|
||||
return event;
|
||||
|
@ -344,7 +344,9 @@ public class GameEvent implements Serializable {
|
|||
return type;
|
||||
}
|
||||
|
||||
public UUID getPluginEventType() { return pluginEventType; }
|
||||
public UUID getCustomEventType() {
|
||||
return customEventType;
|
||||
}
|
||||
|
||||
public UUID getTargetId() {
|
||||
return targetId;
|
||||
|
@ -412,8 +414,8 @@ public class GameEvent implements Serializable {
|
|||
return appliedEffects;
|
||||
}
|
||||
|
||||
public boolean isPluginEvent(UUID pluginEventType) {
|
||||
return type == EventType.PLUGIN_EVENT && this.pluginEventType.equals(pluginEventType);
|
||||
public boolean isCustomEvent(UUID customEventType) {
|
||||
return type == EventType.CUSTOM_EVENT && this.customEventType.equals(customEventType);
|
||||
}
|
||||
|
||||
public void setAppliedEffects(ArrayList<UUID> appliedEffects) {
|
||||
|
|
Loading…
Reference in a new issue