mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +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 EssentialsEntityListener entityListener;
|
||||||
private JailPlayerListener jailPlayerListener;
|
private JailPlayerListener jailPlayerListener;
|
||||||
private TNTExplodeListener tntListener;
|
private TNTExplodeListener tntListener;
|
||||||
|
private EssentialsDependancyChecker essDep;
|
||||||
private static Essentials instance = null;
|
private static Essentials instance = null;
|
||||||
private Spawn spawn;
|
private Spawn spawn;
|
||||||
private Jail jail;
|
private Jail jail;
|
||||||
@ -116,6 +117,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
confList.add(worth);
|
confList.add(worth);
|
||||||
reload();
|
reload();
|
||||||
backup = new Backup(this);
|
backup = new Backup(this);
|
||||||
|
essDep = new EssentialsDependancyChecker(this);
|
||||||
|
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
for (Plugin plugin : pm.getPlugins())
|
for (Plugin plugin : pm.getPlugins())
|
||||||
@ -183,7 +185,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
|
|
||||||
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
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);
|
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,4 +758,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
{
|
{
|
||||||
return tntListener;
|
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();
|
List<String> getBannedIps();
|
||||||
|
|
||||||
TNTExplodeListener getTNTListener();
|
TNTExplodeListener getTNTListener();
|
||||||
|
|
||||||
|
EssentialsDependancyChecker getDependancyChecker();
|
||||||
}
|
}
|
||||||
|
@ -306,3 +306,6 @@ msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
|||||||
kits = \u00a77Kits: {0}
|
kits = \u00a77Kits: {0}
|
||||||
loadWarpError = Failed to load warp {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
|
@ -308,3 +308,6 @@ msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
|||||||
kits = \u00a77Pakker: {0}
|
kits = \u00a77Pakker: {0}
|
||||||
loadWarpError = Kunne ikke indl\u00e6se warp {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
|
@ -306,3 +306,6 @@ msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
|||||||
kits = \u00a77Ausr\u00fcstungen: {0}
|
kits = \u00a77Ausr\u00fcstungen: {0}
|
||||||
loadWarpError = Fehler beim Laden von Warp-Punkt {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
|
@ -306,3 +306,6 @@ msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
|||||||
kits = \u00a77Kits: {0}
|
kits = \u00a77Kits: {0}
|
||||||
loadWarpError = Failed to load warp {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
|
@ -303,3 +303,6 @@ msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
|||||||
kits = \u00a77Kits:{0}
|
kits = \u00a77Kits:{0}
|
||||||
loadWarpError = Echec du chargement du warp {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
|
@ -307,3 +307,6 @@ msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
|
|||||||
kits = \u00a77Kits: {0}
|
kits = \u00a77Kits: {0}
|
||||||
loadWarpError = Fout bij het laden van warp {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>
|
</project>
|
||||||
|
@ -22,7 +22,7 @@ debug.test.classpath=\
|
|||||||
${run.test.classpath}
|
${run.test.classpath}
|
||||||
# This directory is removed when the project is cleaned:
|
# This directory is removed when the project is cleaned:
|
||||||
dist.dir=dist
|
dist.dir=dist
|
||||||
dist.jar=${dist.dir}/original-EssentialsProtect.jar
|
dist.jar=${dist.dir}/EssentialsProtect.jar
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
|
@ -50,14 +50,10 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
|||||||
|
|
||||||
public void onEnable()
|
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;
|
instance = this;
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user