mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
[trunk] Adding dependancy checker, need to fix timings as Protect tries to use it before the file system finishes
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1579 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
1a572bca2e
commit
e94a01b149
@ -50,6 +50,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
private EssentialsEntityListener entityListener;
|
||||
private JailPlayerListener jailPlayerListener;
|
||||
private TNTExplodeListener tntListener;
|
||||
private EssentialsDependancyChecker essDep;
|
||||
private static Essentials instance = null;
|
||||
private Spawn spawn;
|
||||
private Jail jail;
|
||||
@ -116,6 +117,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
confList.add(worth);
|
||||
reload();
|
||||
backup = new Backup(this);
|
||||
essDep = new EssentialsDependancyChecker(this);
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
@ -183,7 +185,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
||||
{
|
||||
logger.log(Level.WARNING, "Old nether is disabled until multiworld support in bukkit is fixed.");
|
||||
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||
}
|
||||
|
||||
@ -757,4 +758,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return tntListener;
|
||||
}
|
||||
|
||||
public EssentialsDependancyChecker getDependancyChecker()
|
||||
{
|
||||
return essDep;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class EssentialsDependancyChecker
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
final Essentials ess;
|
||||
|
||||
public EssentialsDependancyChecker(Essentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void checkProtectDependancies()
|
||||
{
|
||||
final String dependancyLocation = "http://mirrors.ibiblio.org/pub/mirrors/maven2/c3p0/c3p0/0.9.1.2/c3p0-0.9.1.2.jar";
|
||||
File dependancyFile = new File("lib/c3p0-0.9.1.2.jar");
|
||||
if (!dependancyFile.exists())
|
||||
{
|
||||
logger.log(Level.INFO, Util.i18n("dependancyNotFound"));
|
||||
try
|
||||
{
|
||||
URL url = new URL(dependancyLocation);
|
||||
BufferedInputStream inStream = new BufferedInputStream(url.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(dependancyFile);
|
||||
BufferedOutputStream outStream = new BufferedOutputStream(fos, 1024);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
|
||||
while ((len = inStream.read(buffer)) > 0)
|
||||
{
|
||||
outStream.write(buffer, 0, len);
|
||||
}
|
||||
outStream.close();
|
||||
fos.close();
|
||||
inStream.close();
|
||||
logger.log(Level.INFO, Util.format("dependancyDownloaded", dependancyFile.getName()));
|
||||
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("urlMalformed"), ex);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("dependancyException"), ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("dependancyException"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -69,4 +69,6 @@ public interface IEssentials
|
||||
List<String> getBannedIps();
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
EssentialsDependancyChecker getDependancyChecker();
|
||||
}
|
||||
|
@ -305,4 +305,7 @@ timePattern = (?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:
|
||||
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
||||
kits = \u00a77Kits: {0}
|
||||
loadWarpError = Failed to load warp {0}
|
||||
invalidSignLine = Line {0} on sign is invalid.
|
||||
invalidSignLine = Line {0} on sign is invalid.
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
@ -307,4 +307,7 @@ timePattern = (?:([0-9]+)\\s*[a\u00e5y][a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\
|
||||
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
||||
kits = \u00a77Pakker: {0}
|
||||
loadWarpError = Kunne ikke indl\u00e6se warp {0}
|
||||
invalidSignLine = Linje {0} p\u00e5 skilt er ugyldig.
|
||||
invalidSignLine = Linje {0} p\u00e5 skilt er ugyldig.
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
@ -305,4 +305,7 @@ timePattern = (?:([0-9]+)\\s*[yj][a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?
|
||||
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
||||
kits = \u00a77Ausr\u00fcstungen: {0}
|
||||
loadWarpError = Fehler beim Laden von Warp-Punkt {0}
|
||||
invalidSignLine = Die Zeile {0} auf dem Schild ist falsch.
|
||||
invalidSignLine = Die Zeile {0} auf dem Schild ist falsch.
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
@ -305,4 +305,7 @@ timePattern = (?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:
|
||||
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
||||
kits = \u00a77Kits: {0}
|
||||
loadWarpError = Failed to load warp {0}
|
||||
invalidSignLine = Line {0} on sign is invalid.
|
||||
invalidSignLine = Line {0} on sign is invalid.
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
@ -302,4 +302,7 @@ timePattern = (?:([0-9]+)\\s*[ya][a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?
|
||||
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
||||
kits = \u00a77Kits:{0}
|
||||
loadWarpError = Echec du chargement du warp {0}
|
||||
invalidSignLine = Ligne {0} du panneau est invalide.
|
||||
invalidSignLine = Ligne {0} du panneau est invalide.
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
@ -306,4 +306,7 @@ timePattern = (?:([0-9]+)\\s*[yj][a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[oa][a-z]*[,\\s]
|
||||
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
||||
kits = \u00a77Kits: {0}
|
||||
loadWarpError = Fout bij het laden van warp {0}
|
||||
invalidSignLine = Regel {0} op het bordje is ongeldig.
|
||||
invalidSignLine = Regel {0} op het bordje is ongeldig.
|
||||
dependancyNotFound = [Essentials] A required dependancy was not found, downloading now.
|
||||
dependancyDownloaded = [Essentials] Dependancy {0} downloaded successfully.
|
||||
dependancyException = [Essentials] An error occured when trying to download a dependacy
|
@ -73,13 +73,4 @@
|
||||
|
||||
-->
|
||||
|
||||
<target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/EssentialsProtect.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="../lib/c3p0-0.9.1.2.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
|
@ -1,87 +1,87 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=EssentialsProtect
|
||||
application.vendor=devhome
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
build.generated.sources.dir=${build.dir}/generated-sources
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
# Uncomment to specify the preferred debugger connection transport:
|
||||
#debug.transport=dt_socket
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/original-EssentialsProtect.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.c3p0-0.9.1.2.jar=..\\lib\\c3p0-0.9.1.2.jar
|
||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=false
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.c3p0-0.9.1.2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}:\
|
||||
${libs.junit_4.classpath}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
jnlp.mixed.code=defaut
|
||||
jnlp.offline-allowed=false
|
||||
jnlp.signed=false
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
project.Essentials=../Essentials
|
||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
source.encoding=UTF-8
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=EssentialsProtect
|
||||
application.vendor=devhome
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
build.generated.sources.dir=${build.dir}/generated-sources
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
# Uncomment to specify the preferred debugger connection transport:
|
||||
#debug.transport=dt_socket
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/EssentialsProtect.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.c3p0-0.9.1.2.jar=..\\lib\\c3p0-0.9.1.2.jar
|
||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=false
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.c3p0-0.9.1.2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}:\
|
||||
${libs.junit_4.classpath}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
jnlp.mixed.code=defaut
|
||||
jnlp.offline-allowed=false
|
||||
jnlp.signed=false
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
project.Essentials=../Essentials
|
||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
source.encoding=UTF-8
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
|
@ -50,14 +50,10 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
ess = Essentials.getStatic();
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
Essentials ess = (Essentials)pm.getPlugin("Essentials");
|
||||
if (!ess.isEnabled())
|
||||
{
|
||||
pm.enablePlugin(ess);
|
||||
}
|
||||
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
ess = Essentials.getStatic();
|
||||
ess.getDependancyChecker().checkProtectDependancies();
|
||||
instance = this;
|
||||
reloadConfig();
|
||||
|
||||
@ -77,7 +73,7 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
||||
pm.registerEvent(Type.LIGHTNING_STRIKE, weatherListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.THUNDER_CHANGE, weatherListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.WEATHER_CHANGE, weatherListener, Priority.Highest, this);
|
||||
|
||||
|
||||
if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version.");
|
||||
|
Loading…
Reference in New Issue
Block a user