1.4.0 rc2

This commit is contained in:
Tyler Murphy 2022-04-13 12:02:36 -04:00
parent 38fd4f5740
commit 3794537cf4
5 changed files with 45 additions and 26 deletions

30
pom.xml
View file

@ -26,31 +26,31 @@
<relocations> <relocations>
<relocation> <relocation>
<pattern>com.cryptomorin.xseries</pattern> <pattern>com.cryptomorin.xseries</pattern>
<shadedPattern>net.tylermurphy.hideAndSeek.util.xseries</shadedPattern> <shadedPattern>net.tylermurphy.xseries</shadedPattern>
</relocation> </relocation>
</relocations> </relocations>
<artifactSet> <artifactSet>
<includes> <excludes>
<include>com.github.cryptomorin:XSeries</include> <exclude>org.spigotmc:spigot-api</exclude>
<include>org.xerial:sqlite-jdbc</include> <exclude>com.comphenix.protocol:ProtocolLib</exclude>
</includes> <exclude>org.jetbrains:annotations</exclude>
<exclude>net.bytebuddy:byte-buddy</exclude>
</excludes>
</artifactSet> </artifactSet>
<filters> <filters>
<filter> <filter>
<artifact>*:*</artifact> <artifact>*:*</artifact>
<excludes> <excludes>
<exclude>META-INF/*.MF</exclude> <exclude>META-INF/*.MF</exclude>
<exclude>com/cryptomorin/xseries/XBiome*</exclude> <exclude>sqlite-jdbc.properties</exclude>
<exclude>com/cryptomorin/xseries/NMSExtras*</exclude>
<exclude>com/cryptomorin/xseries/NoteBlockMusic*</exclude>
<exclude>com/cryptomorin/xseries/SkullCacheListener*</exclude>
<exclude>com/cryptomorin/xseries/XBlock*</exclude>
<exclude>com/cryptomorin/xseries/XEntity*</exclude>
<exclude>com/cryptomorin/xseries/particles/*</exclude>
<exclude>com/cryptomorin/xseries/messages/ActionBar*</exclude>
</excludes> </excludes>
</filter> </filter>
</filters> </filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/java.sql.Driver</resource>
</transformer>
</transformers>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
@ -89,9 +89,7 @@
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version> <version>3.7.2</version>
<type>jar</type>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jetbrains</groupId> <groupId>org.jetbrains</groupId>

View file

@ -36,7 +36,7 @@ public class Localization {
public static void loadLocalization() { public static void loadLocalization() {
ConfigManager manager = new ConfigManager("localization.yml", "lang"+File.separator+"localization_"+Config.locale +".yml"); ConfigManager manager = new ConfigManager("localization.yml", "lang/localization_"+Config.locale +".yml");
int PLUGIN_VERSION = manager.getDefaultInt("version"); int PLUGIN_VERSION = manager.getDefaultInt("version");
int VERSION = manager.getInt("version"); int VERSION = manager.getInt("version");

View file

@ -21,6 +21,8 @@ package net.tylermurphy.hideAndSeek.database;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import org.sqlite.SQLiteConfig;
import sun.font.ScriptRun;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
@ -30,6 +32,8 @@ import java.nio.ByteBuffer;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
import java.util.UUID; import java.util.UUID;
public class Database { public class Database {
@ -37,14 +41,15 @@ public class Database {
private static final File databaseFile = new File(Main.data, "database.db"); private static final File databaseFile = new File(Main.data, "database.db");
public static PlayerInfoTable playerInfo; public static PlayerInfoTable playerInfo;
private static SQLiteConfig config;
protected static Connection connect() { protected static Connection connect() {
Connection conn = null; Connection conn = null;
try { try {
String url = "jdbc:sqlite:"+databaseFile; String url = "jdbc:sqlite:"+databaseFile;
conn = DriverManager.getConnection(url); conn = DriverManager.getConnection(url, config.toProperties());
} catch (SQLException e) { } catch (SQLException e) {
System.out.println(e.getMessage()); Main.plugin.getLogger().severe(e.getMessage());
} }
return conn; return conn;
} }
@ -71,10 +76,15 @@ public class Database {
try { try {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
Main.plugin.getLogger().severe("Unable to load SQLite driver!"); Main.plugin.getLogger().severe(e.getMessage());
System.exit(-1); throw new RuntimeException(e.getMessage());
return;
} }
config = new SQLiteConfig();
config.setSynchronous(SQLiteConfig.SynchronousMode.NORMAL);
config.setTempStore(SQLiteConfig.TempStore.MEMORY);
playerInfo = new PlayerInfoTable(); playerInfo = new PlayerInfoTable();
} }
} }

View file

@ -20,8 +20,10 @@
package net.tylermurphy.hideAndSeek.database; package net.tylermurphy.hideAndSeek.database;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.util.WinType; import net.tylermurphy.hideAndSeek.util.WinType;
import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.*; import java.sql.*;
@ -42,7 +44,7 @@ public class PlayerInfoTable {
+ ");"; + ");";
try(Connection connection = Database.connect(); Statement statement = connection.createStatement()){ try(Connection connection = Database.connect(); Statement statement = connection.createStatement()){
statement.execute(sql); statement.executeUpdate(sql);
} catch (SQLException e){ } catch (SQLException e){
Main.plugin.getLogger().severe("SQL Error: " + e.getMessage()); Main.plugin.getLogger().severe("SQL Error: " + e.getMessage());
} }
@ -59,6 +61,8 @@ public class PlayerInfoTable {
statement.setBytes(1, bytes); statement.setBytes(1, bytes);
ResultSet rs = statement.executeQuery(); ResultSet rs = statement.executeQuery();
if(rs.next()){ if(rs.next()){
rs.close();
connection.close();
return new PlayerInfo( return new PlayerInfo(
uuid, uuid,
rs.getInt("wins"), rs.getInt("wins"),
@ -67,6 +71,7 @@ public class PlayerInfoTable {
rs.getInt("games_played") rs.getInt("games_played")
); );
} }
rs.close();
} catch (SQLException e){ } catch (SQLException e){
Main.plugin.getLogger().severe("SQL Error: " + e.getMessage()); Main.plugin.getLogger().severe("SQL Error: " + e.getMessage());
} catch (IOException e) { } catch (IOException e) {
@ -84,7 +89,7 @@ public class PlayerInfoTable {
List<PlayerInfo> infoList = new ArrayList<>(); List<PlayerInfo> infoList = new ArrayList<>();
while(rs.next()){ while(rs.next()){
PlayerInfo info = new PlayerInfo( PlayerInfo info = new PlayerInfo(
Database.convertBinaryStream(rs.getBinaryStream("uuid")), Database.convertBinaryStream(new ByteArrayInputStream(rs.getBytes("uuid"))),
rs.getInt("wins"), rs.getInt("wins"),
rs.getInt("seeker_wins"), rs.getInt("seeker_wins"),
rs.getInt("hider_wins"), rs.getInt("hider_wins"),
@ -92,6 +97,8 @@ public class PlayerInfoTable {
); );
infoList.add(info); infoList.add(info);
} }
rs.close();
connection.close();
return infoList; return infoList;
} catch (SQLException e){ } catch (SQLException e){
Main.plugin.getLogger().severe("SQL Error: " + e.getMessage()); Main.plugin.getLogger().severe("SQL Error: " + e.getMessage());

View file

@ -271,9 +271,13 @@ public class EventListener implements Listener {
} }
} }
} }
String[] temp = array[0].split(":");
for(String handle : blockedCommands){ for(String handle : blockedCommands){
System.out.println(handle); if(
if(array[0].substring(1).equalsIgnoreCase(handle) && Board.isPlayer(player) && Game.status != Status.STANDBY){ array[0].substring(1).equalsIgnoreCase(handle) && Board.isPlayer(player) &&
temp[temp.length-1].substring(1).equalsIgnoreCase(handle) && Board.isPlayer(player) &&
Game.status != Status.STANDBY
) {
player.sendMessage(errorPrefix + message("BLOCKED_COMMAND")); player.sendMessage(errorPrefix + message("BLOCKED_COMMAND"));
event.setCancelled(true); event.setCancelled(true);
break; break;