LoadableModClassPath.java
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
package com.mumfrey.liteloader.core.api;
import java.io.File;
import java.net.MalformedURLException;
import com.mumfrey.liteloader.core.LiteLoaderVersion;
import net.minecraft.launchwrapper.LaunchClassLoader;
/**
* Mod file reference for a file loaded from class path
*
* @author Adam Mummery-Smith
*/
public class LoadableModClassPath extends LoadableModFile
{
private static final long serialVersionUID = -4759310661966590773L;
private boolean modNameRequired = false;
LoadableModClassPath(File file)
{
this(file, null);
}
LoadableModClassPath(File file, String fallbackName)
{
super(file, LoadableModFile.getVersionMetaDataString(file));
if (this.modName == null)
{
if (fallbackName != null)
{
this.modName = fallbackName;
}
else if (this.isFile())
{
this.modName = this.getName().substring(0, this.getName().lastIndexOf('.'));
}
else
{
String parentFileName = this.getParentFile() != null ? this.getParentFile().getName().toLowerCase() : "";
this.modName = String.format("%s.%s", parentFileName, this.getName().toLowerCase());
this.modNameRequired = true;
}
}
if (this.targetVersion == null) this.targetVersion = LiteLoaderVersion.CURRENT.getMinecraftVersion();
}
@Override
protected void readJarMetaData()
{
// Nope
}
@Override
protected String getDefaultName()
{
return null;
}
@Override
public String getDisplayName()
{
return this.getModName();
}
@Override
public boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException
{
// Can't inject a class path entry into the class path!
return false;
}
@Override
public boolean isInjected()
{
return true;
}
@Override
public void addContainedMod(String modName)
{
if (this.modNameRequired)
{
this.modNameRequired = false;
this.modName = modName;
}
}
}