Merge pull request '1.7.3' (#8) from dev into main

Reviewed-on: https://g.tylerm.dev/tylermurphy534/KenshinsHideAndSeek/pulls/8
This commit is contained in:
Freya Murphy 2023-05-27 14:15:46 +00:00
commit 0eaff28415
9 changed files with 61 additions and 39 deletions

Binary file not shown.

23
pom.xml
View file

@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
<groupId>net.tylermurphy</groupId>
<artifactId>KenshinsHideAndSeek</artifactId>
<version>1.7.2</version>
<version>1.7.3</version>
<name>Hide and Seek Plugin</name>
<properties>
@ -15,7 +15,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
@ -62,7 +62,7 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -78,10 +78,10 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository>
<!-- <repository>-->
<!-- <id>dmulloy2-repo</id>-->
<!-- <url>https://repo.dmulloy2.net/repository/public/</url>-->
<!-- </repository>-->
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
@ -104,9 +104,8 @@
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ProtocolLib.jar</systemPath>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
@ -121,7 +120,7 @@
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>9.2.0</version>
<version>9.3.1</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
@ -140,4 +139,4 @@
<version>3.1.2</version>
</dependency>
</dependencies>
</project>
</project>

View file

@ -34,6 +34,7 @@ public class Main extends JavaPlugin implements Listener {
private static Main instance;
private static int version;
private static int sub_version;
private Database database;
private Board board;
@ -189,12 +190,28 @@ public class Main extends JavaPlugin implements Listener {
}
private void updateVersion(){
Matcher matcher = Pattern.compile("MC: \\d\\.(\\d+)").matcher(Bukkit.getVersion());
Matcher matcher = Pattern.compile("MC: \\d\\.(\\d+).(\\d+)").matcher(Bukkit.getVersion());
if (matcher.find()) {
version = Integer.parseInt(matcher.group(1));
} else {
throw new IllegalArgumentException("Failed to parse server version from: " + Bukkit.getVersion());
}
sub_version = Integer.parseInt(matcher.group(2));
getLogger().info("Identified server version: " + version);
getLogger().info("Identified server sub version: " + sub_version);
return;
}
matcher = Pattern.compile("MC: \\d\\.(\\d+)").matcher(Bukkit.getVersion());
if (matcher.find()) {
version = Integer.parseInt(matcher.group(1));
sub_version = 0;
getLogger().info("Identified server version: " + version);
return;
}
throw new IllegalArgumentException("Failed to parse server version from: " + Bukkit.getVersion());
}
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
@ -244,6 +261,10 @@ public class Main extends JavaPlugin implements Listener {
return version >= v;
}
public boolean supports(int v, int s){
return (version == v) ? sub_version >= s : version >= v;
}
public java.util.List<String> getWorlds() {
java.util.List<String> worlds = new ArrayList<>();
File[] containers = getWorldContainer().listFiles();
@ -268,4 +289,4 @@ public class Main extends JavaPlugin implements Listener {
Bukkit.getServer().getScheduler().runTask(this, task);
}
}
}

View file

@ -49,6 +49,7 @@ public class Status implements ICommand {
}
if (map.isBlockHuntEnabled() && map.getBlockHunt().isEmpty()) {
msg = msg + "\n" + message("SETUP_BLOCKHUNT");
count++;
}
if (count < 1) {
sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
@ -76,4 +77,4 @@ public class Status implements ICommand {
return null;
}
}
}

View file

@ -51,7 +51,7 @@ public class CommandGroup {
if (data == null) {
player.sendMessage(
String.format("%s%sKenshin's Hide and Seek %s(%s1.7.2%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY, ChatColor.WHITE, ChatColor.GRAY) +
String.format("%s%sKenshin's Hide and Seek %s(%s1.7.3%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY, ChatColor.WHITE, ChatColor.GRAY) +
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);

View file

@ -1,21 +1,22 @@
package net.tylermurphy.hideAndSeek.database;
import com.google.common.io.ByteStreams;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.database.connections.DatabaseConnection;
import net.tylermurphy.hideAndSeek.database.connections.MySQLConnection;
import net.tylermurphy.hideAndSeek.database.connections.SQLiteConnection;
import static net.tylermurphy.hideAndSeek.configuration.Config.databaseType;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.UUID;
import static net.tylermurphy.hideAndSeek.configuration.Config.databasePort;
import static net.tylermurphy.hideAndSeek.configuration.Config.databaseType;
import com.google.common.io.ByteStreams;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.database.connections.DatabaseConnection;
import net.tylermurphy.hideAndSeek.database.connections.MySQLConnection;
import net.tylermurphy.hideAndSeek.database.connections.SQLiteConnection;
public class Database {
@ -96,7 +97,7 @@ public class Database {
ByteBuffer buffer = ByteBuffer.allocate(16);
try {
buffer.put(ByteStreams.toByteArray(is));
buffer.flip();
((Buffer)buffer).flip();
return new UUID(buffer.getLong(), buffer.getLong());
} catch (IOException e) {
Main.getInstance().getLogger().severe("IO Error: " + e.getMessage());

View file

@ -9,6 +9,7 @@ import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.WrappedEnumEntityUseAction;
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.messages.ActionBar;
import net.tylermurphy.hideAndSeek.Main;
@ -54,9 +55,9 @@ public class DisguiseHandler implements Listener {
PacketContainer packet = event.getPacket();
// only left click attacks
WrappedEnumEntityUseAction action = packet.getEnumEntityUseActions().getValues().stream().findFirst().orElse(null);
EntityUseAction action = packet.getEntityUseActions().getValues().stream().findFirst().orElse(null);
if (action == null) return;
if (action.getAction() != EnumWrappers.EntityUseAction.ATTACK) return;
if (action != EnumWrappers.EntityUseAction.ATTACK) return;
Player player = event.getPlayer();
int id = packet.getIntegers().read(0);

View file

@ -4,6 +4,9 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.wrappers.WrappedDataValue;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
@ -36,12 +39,7 @@ public class EntityMetadataPacket extends AbstractPacket {
public void writeMetadata() {
// thank you to
// https://www.spigotmc.org/threads/unable-to-modify-entity-metadata-packet-using-protocollib-1-19-3.582442/
try {
// 1.19.3 And Up
Class.forName("com.comphenix.protocol.wrappers.WrappedDataValue");
if (Main.getInstance().supports(19, 3)) {
final List<WrappedDataValue> wrappedDataValueList = new ArrayList<>();
@ -60,11 +58,12 @@ public class EntityMetadataPacket extends AbstractPacket {
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
} catch (ClassCastException | ClassNotFoundException ignored) {
// 1.9 to 1.19.2 And Up
} else {
packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
}
}
}
}

View file

@ -1,6 +1,6 @@
name: KenshinsHideAndSeek
main: net.tylermurphy.hideAndSeek.Main
version: 1.7.2
version: 1.7.3
author: KenshinEto
load: STARTUP
api-version: 1.13