mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-15 11:04:29 +02:00
Revert "I honestly have no idea if this works, but on paper it does. Will be great, now to figure out how to test." until there is a real alternative.
This reverts commit 7b8a9d60d7
.
This commit is contained in:
@@ -72,7 +72,7 @@
|
|||||||
nbproject/build-impl.xml file.
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<!--<target name="-post-jar">
|
<target name="-post-jar">
|
||||||
<jar jarfile="${dist.dir}/EssentialsProtect.jar">
|
<jar jarfile="${dist.dir}/EssentialsProtect.jar">
|
||||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||||
<zipfileset src="../lib/c3p0-0.9.1.2.jar" excludes="META-INF/*" />
|
<zipfileset src="../lib/c3p0-0.9.1.2.jar" excludes="META-INF/*" />
|
||||||
@@ -80,5 +80,5 @@
|
|||||||
<attribute name="Classpath" value="EssentialsProtect.jar"/>
|
<attribute name="Classpath" value="EssentialsProtect.jar"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
</target>-->
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -64,12 +64,14 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
|||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||||
|
file.reference.c3p0-0.9.1.2.jar=..\\lib\\c3p0-0.9.1.2.jar
|
||||||
includes=**
|
includes=**
|
||||||
jar.archive.disabled=${jnlp.enabled}
|
jar.archive.disabled=${jnlp.enabled}
|
||||||
jar.compress=true
|
jar.compress=true
|
||||||
jar.index=${jnlp.enabled}
|
jar.index=${jnlp.enabled}
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${reference.Essentials.jar}:\
|
${reference.Essentials.jar}:\
|
||||||
|
${file.reference.c3p0-0.9.1.2.jar}:\
|
||||||
${file.reference.bukkit.jar}
|
${file.reference.bukkit.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
|
@@ -66,6 +66,10 @@ public class EssentialsConnect
|
|||||||
@Override
|
@Override
|
||||||
public void onReload()
|
public void onReload()
|
||||||
{
|
{
|
||||||
|
if (protect.getStorage() != null)
|
||||||
|
{
|
||||||
|
protect.getStorage().onPluginDeactivation();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for (ProtectConfig protectConfig : ProtectConfig.values()) { if (protectConfig.isList()) {
|
* for (ProtectConfig protectConfig : ProtectConfig.values()) { if (protectConfig.isList()) {
|
||||||
@@ -93,7 +97,7 @@ public class EssentialsConnect
|
|||||||
settings.getData().getDbuser(),
|
settings.getData().getDbuser(),
|
||||||
settings.getData().getDbpassword()));
|
settings.getData().getDbpassword()));
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex)
|
catch (PropertyVetoException ex)
|
||||||
{
|
{
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
LOGGER.log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
@@ -104,15 +108,15 @@ public class EssentialsConnect
|
|||||||
{
|
{
|
||||||
protect.setStorage(new ProtectedBlockSQLite("jdbc:sqlite:plugins/Essentials/EssentialsProtect.db"));
|
protect.setStorage(new ProtectedBlockSQLite("jdbc:sqlite:plugins/Essentials/EssentialsProtect.db"));
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex)
|
catch (PropertyVetoException ex)
|
||||||
{
|
{
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
LOGGER.log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*if (protect.getSettingBool(ProtectConfig.memstore))
|
||||||
* if (protect.getSettingBool(ProtectConfig.memstore)) { protect.setStorage(new
|
{
|
||||||
* ProtectedBlockMemory(protect.getStorage(), protect)); }
|
protect.setStorage(new ProtectedBlockMemory(protect.getStorage(), protect));
|
||||||
*/
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
package com.earth2me.essentials.protect;
|
package com.earth2me.essentials.protect;
|
||||||
|
|
||||||
import com.earth2me.essentials.protect.data.IProtectedBlock;
|
import com.earth2me.essentials.protect.data.IProtectedBlock;
|
||||||
|
import java.util.logging.Filter;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@@ -12,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
public class EssentialsProtect extends JavaPlugin implements IProtect
|
public class EssentialsProtect extends JavaPlugin implements IProtect
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||||
|
private static com.mchange.v2.log.MLogger C3P0logger;
|
||||||
//private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
|
//private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
|
||||||
//private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
|
//private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
|
||||||
//private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
|
//private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
|
||||||
@@ -20,6 +23,18 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
|||||||
private transient ProtectHolder settings = null;
|
private transient ProtectHolder settings = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void onLoad()
|
||||||
|
{
|
||||||
|
C3P0logger = com.mchange.v2.log.MLog.getLogger(com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.class);
|
||||||
|
C3P0logger.setFilter(new Filter()
|
||||||
|
{
|
||||||
|
public boolean isLoggable(LogRecord lr)
|
||||||
|
{
|
||||||
|
return lr.getLevel() != Level.INFO;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
final PluginManager pm = this.getServer().getPluginManager();
|
final PluginManager pm = this.getServer().getPluginManager();
|
||||||
@@ -56,10 +71,13 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
|||||||
LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essenials Protect is in emergency mode now.");
|
LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essenials Protect is in emergency mode now.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*@Override
|
||||||
* @Override public boolean checkProtectionItems(final ProtectConfig list, final int id) { final List<Integer>
|
public boolean checkProtectionItems(final ProtectConfig list, final int id)
|
||||||
* itemList = settingsList.get(list); return itemList != null && !itemList.isEmpty() && itemList.contains(id); }
|
{
|
||||||
*/
|
final List<Integer> itemList = settingsList.get(list);
|
||||||
|
return itemList != null && !itemList.isEmpty() && itemList.contains(id);
|
||||||
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IProtectedBlock getStorage()
|
public IProtectedBlock getStorage()
|
||||||
{
|
{
|
||||||
@@ -77,19 +95,51 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
|
|||||||
return ess;
|
return ess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*public Map<ProtectConfig, Boolean> getSettingsBoolean()
|
||||||
* public Map<ProtectConfig, Boolean> getSettingsBoolean() { return settingsBoolean; }
|
{
|
||||||
*
|
return settingsBoolean;
|
||||||
* public Map<ProtectConfig, String> getSettingsString() { return settingsString; }
|
}
|
||||||
*
|
|
||||||
* public Map<ProtectConfig, List<Integer>> getSettingsList() { return settingsList; }
|
public Map<ProtectConfig, String> getSettingsString()
|
||||||
*
|
{
|
||||||
* @Override public boolean getSettingBool(final ProtectConfig protectConfig) { final Boolean bool =
|
return settingsString;
|
||||||
* settingsBoolean.get(protectConfig); return bool == null ? protectConfig.getDefaultValueBoolean() : bool; }
|
}
|
||||||
*
|
|
||||||
* @Override public String getSettingString(final ProtectConfig protectConfig) { final String str =
|
public Map<ProtectConfig, List<Integer>> getSettingsList()
|
||||||
* settingsString.get(protectConfig); return str == null ? protectConfig.getDefaultValueString() : str; }
|
{
|
||||||
*/
|
return settingsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getSettingBool(final ProtectConfig protectConfig)
|
||||||
|
{
|
||||||
|
final Boolean bool = settingsBoolean.get(protectConfig);
|
||||||
|
return bool == null ? protectConfig.getDefaultValueBoolean() : bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSettingString(final ProtectConfig protectConfig)
|
||||||
|
{
|
||||||
|
final String str = settingsString.get(protectConfig);
|
||||||
|
return str == null ? protectConfig.getDefaultValueString() : str;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
if (storage != null)
|
||||||
|
{
|
||||||
|
storage.onPluginDeactivation();
|
||||||
|
}
|
||||||
|
// Sleep for a second to allow the database to close.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ProtectHolder getSettings()
|
public ProtectHolder getSettings()
|
||||||
{
|
{
|
||||||
return settings;
|
return settings;
|
||||||
|
@@ -19,4 +19,6 @@ public interface IProtectedBlock
|
|||||||
public List<String> getOwners(Block block);
|
public List<String> getOwners(Block block);
|
||||||
|
|
||||||
public int unprotectBlock(Block block);
|
public int unprotectBlock(Block block);
|
||||||
|
|
||||||
|
public void onPluginDeactivation();
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,11 @@
|
|||||||
package com.earth2me.essentials.protect.data;
|
package com.earth2me.essentials.protect.data;
|
||||||
|
|
||||||
import java.sql.*;
|
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -11,7 +16,7 @@ import org.bukkit.block.Block;
|
|||||||
public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger("Minecraft");
|
protected static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||||
protected String url;
|
protected final transient ComboPooledDataSource cpds;
|
||||||
|
|
||||||
protected abstract PreparedStatement getStatementCreateTable(Connection conn) throws SQLException;
|
protected abstract PreparedStatement getStatementCreateTable(Connection conn) throws SQLException;
|
||||||
|
|
||||||
@@ -29,20 +34,22 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
|
|
||||||
protected abstract PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException;
|
protected abstract PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException;
|
||||||
|
|
||||||
public ProtectedBlockJDBC(String driver, String url) throws ClassNotFoundException
|
public ProtectedBlockJDBC(String driver, String url) throws PropertyVetoException
|
||||||
{
|
{
|
||||||
this(driver, url, null, null);
|
this(driver, url, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtectedBlockJDBC(String driver, String url, String username, String password) throws ClassNotFoundException
|
public ProtectedBlockJDBC(String driver, String url, String username, String password) throws PropertyVetoException
|
||||||
{
|
{
|
||||||
Class.forName(driver);
|
cpds = new ComboPooledDataSource();
|
||||||
this.url = url;
|
cpds.setDriverClass(driver);
|
||||||
|
cpds.setJdbcUrl(url);
|
||||||
if (username != null)
|
if (username != null)
|
||||||
{
|
{
|
||||||
url += "?user=" + username;
|
cpds.setUser(username);
|
||||||
url += "&password=" + password;
|
cpds.setPassword(password);
|
||||||
}
|
}
|
||||||
|
cpds.setMaxStatements(20);
|
||||||
createAndConvertTable();
|
createAndConvertTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +59,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = DriverManager.getConnection(url);
|
conn = cpds.getConnection();
|
||||||
ps = getStatementCreateTable(conn);
|
ps = getStatementCreateTable(conn);
|
||||||
ps.execute();
|
ps.execute();
|
||||||
ps.close();
|
ps.close();
|
||||||
@@ -96,7 +103,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = DriverManager.getConnection(url);
|
conn = cpds.getConnection();
|
||||||
ps = getStatementDeleteAll(conn);
|
ps = getStatementDeleteAll(conn);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
}
|
}
|
||||||
@@ -151,7 +158,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
List<OwnedBlock> blocks = new ArrayList<OwnedBlock>();
|
List<OwnedBlock> blocks = new ArrayList<OwnedBlock>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = DriverManager.getConnection(url);
|
conn = cpds.getConnection();
|
||||||
ps = getStatementAllBlocks(conn);
|
ps = getStatementAllBlocks(conn);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
@@ -220,7 +227,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = DriverManager.getConnection(url);
|
conn = cpds.getConnection();
|
||||||
ps = getStatementInsert(conn, world, x, y, z, playerName);
|
ps = getStatementInsert(conn, world, x, y, z, playerName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
}
|
}
|
||||||
@@ -262,7 +269,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = DriverManager.getConnection(url);
|
conn = cpds.getConnection();
|
||||||
ps = getStatementPlayerCountByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), playerName);
|
ps = getStatementPlayerCountByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), playerName);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
return rs.next() && rs.getInt(1) > 0 && rs.getInt(2) == 0;
|
return rs.next() && rs.getInt(1) > 0 && rs.getInt(2) == 0;
|
||||||
@@ -318,7 +325,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
List<String> owners = new ArrayList<String>();
|
List<String> owners = new ArrayList<String>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = DriverManager.getConnection(url);
|
conn = cpds.getConnection();
|
||||||
ps = getStatementPlayersByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ());
|
ps = getStatementPlayersByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ());
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
@@ -376,7 +383,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
conn = DriverManager.getConnection(url);
|
conn = cpds.getConnection();
|
||||||
ps = getStatementDeleteByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ());
|
ps = getStatementDeleteByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ());
|
||||||
return ps.executeUpdate();
|
return ps.executeUpdate();
|
||||||
}
|
}
|
||||||
@@ -411,4 +418,9 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPluginDeactivation()
|
||||||
|
{
|
||||||
|
cpds.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -240,4 +240,9 @@ public class ProtectedBlockMemory implements IProtectedBlock
|
|||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPluginDeactivation()
|
||||||
|
{
|
||||||
|
storage.onPluginDeactivation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.protect.data;
|
package com.earth2me.essentials.protect.data;
|
||||||
|
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -10,7 +11,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class ProtectedBlockMySQL extends ProtectedBlockJDBC
|
public class ProtectedBlockMySQL extends ProtectedBlockJDBC
|
||||||
{
|
{
|
||||||
public ProtectedBlockMySQL(String url, String username, String password) throws ClassNotFoundException
|
public ProtectedBlockMySQL(String url, String username, String password) throws PropertyVetoException
|
||||||
{
|
{
|
||||||
super("com.mysql.jdbc.Driver", url, username, password);
|
super("com.mysql.jdbc.Driver", url, username, password);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.protect.data;
|
package com.earth2me.essentials.protect.data;
|
||||||
|
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -7,7 +8,7 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
public class ProtectedBlockSQLite extends ProtectedBlockJDBC
|
public class ProtectedBlockSQLite extends ProtectedBlockJDBC
|
||||||
{
|
{
|
||||||
public ProtectedBlockSQLite(String url) throws ClassNotFoundException
|
public ProtectedBlockSQLite(String url) throws PropertyVetoException
|
||||||
{
|
{
|
||||||
super("org.sqlite.JDBC", url);
|
super("org.sqlite.JDBC", url);
|
||||||
}
|
}
|
||||||
|
BIN
lib/c3p0-0.9.1.2.jar
Normal file
BIN
lib/c3p0-0.9.1.2.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user