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

View file

@ -36,7 +36,7 @@ public class Localization {
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 VERSION = manager.getInt("version");

View file

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

View file

@ -20,8 +20,10 @@
package net.tylermurphy.hideAndSeek.database;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.util.WinType;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
@ -42,7 +44,7 @@ public class PlayerInfoTable {
+ ");";
try(Connection connection = Database.connect(); Statement statement = connection.createStatement()){
statement.execute(sql);
statement.executeUpdate(sql);
} catch (SQLException e){
Main.plugin.getLogger().severe("SQL Error: " + e.getMessage());
}
@ -59,6 +61,8 @@ public class PlayerInfoTable {
statement.setBytes(1, bytes);
ResultSet rs = statement.executeQuery();
if(rs.next()){
rs.close();
connection.close();
return new PlayerInfo(
uuid,
rs.getInt("wins"),
@ -67,6 +71,7 @@ public class PlayerInfoTable {
rs.getInt("games_played")
);
}
rs.close();
} catch (SQLException e){
Main.plugin.getLogger().severe("SQL Error: " + e.getMessage());
} catch (IOException e) {
@ -84,7 +89,7 @@ public class PlayerInfoTable {
List<PlayerInfo> infoList = new ArrayList<>();
while(rs.next()){
PlayerInfo info = new PlayerInfo(
Database.convertBinaryStream(rs.getBinaryStream("uuid")),
Database.convertBinaryStream(new ByteArrayInputStream(rs.getBytes("uuid"))),
rs.getInt("wins"),
rs.getInt("seeker_wins"),
rs.getInt("hider_wins"),
@ -92,6 +97,8 @@ public class PlayerInfoTable {
);
infoList.add(info);
}
rs.close();
connection.close();
return infoList;
} catch (SQLException e){
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){
System.out.println(handle);
if(array[0].substring(1).equalsIgnoreCase(handle) && Board.isPlayer(player) && Game.status != Status.STANDBY){
if(
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"));
event.setCancelled(true);
break;