1.9.3
This commit is contained in:
parent
5cb48102c2
commit
338e4c8a0f
4 changed files with 52 additions and 55 deletions
|
|
@ -12,9 +12,7 @@ import java.sql.Connection;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class MySQLConnection {
|
||||
|
||||
|
|
@ -76,7 +74,7 @@ public class MySQLConnection {
|
|||
|
||||
ResultSet result = statement.executeQuery();
|
||||
|
||||
Set<String> existingUUIDs = new HashSet<>();
|
||||
Map<String, PlayerData> playerMap = new HashMap<>();
|
||||
while(result.next()){
|
||||
String uuid = result.getString("UUID");
|
||||
String playerName = result.getString("PLAYER_NAME");
|
||||
|
|
@ -85,17 +83,13 @@ public class MySQLConnection {
|
|||
boolean oneTime = result.getBoolean("ONE_TIME");
|
||||
boolean bought = result.getBoolean("BOUGHT");
|
||||
|
||||
PlayerData currentPlayer;
|
||||
if(!existingUUIDs.contains(uuid)){
|
||||
PlayerData player = playerMap.get(uuid);
|
||||
|
||||
if(player == null){
|
||||
//Create and add it
|
||||
currentPlayer = new PlayerData(playerName,uuid);
|
||||
players.add(currentPlayer);
|
||||
existingUUIDs.add(uuid);
|
||||
}else{
|
||||
currentPlayer = players.stream()
|
||||
.filter(p -> p.getUuid().equals(uuid))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
player = new PlayerData(playerName,uuid);
|
||||
players.add(player);
|
||||
playerMap.put(uuid, player);
|
||||
}
|
||||
|
||||
if(kitName != null){
|
||||
|
|
@ -103,7 +97,7 @@ public class MySQLConnection {
|
|||
playerDataKit.setCooldown(cooldown);
|
||||
playerDataKit.setOneTime(oneTime);
|
||||
playerDataKit.setBought(bought);
|
||||
currentPlayer.addKit(playerDataKit);
|
||||
player.addKit(playerDataKit);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class PKInventoryInvalidSlotError extends PKBaseError{
|
|||
hover.add("&eTHIS IS AN ERROR!");
|
||||
hover.add("&fSlot &c"+slot+" &fon inventory &c"+inventoryName);
|
||||
hover.add("&fis out of range. Use a range");
|
||||
hover.add("&fbetween 0 and "+maxSlots+".");
|
||||
hover.add("&fbetween 0 and "+(maxSlots-1)+".");
|
||||
|
||||
jsonMessage.hover(hover).send();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
|
@ -130,7 +132,6 @@ public class ItemUtils {
|
|||
return kitItemSkullData;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setSkullData(ItemStack item, KitItemSkullData skullData, Player player){
|
||||
String typeName = item.getType().name();
|
||||
if(!typeName.equals("PLAYER_HEAD") && !typeName.equals("SKULL_ITEM")) {
|
||||
|
|
@ -148,12 +149,11 @@ public class ItemUtils {
|
|||
}
|
||||
String id = skullData.getId();
|
||||
SkullMeta skullMeta = (SkullMeta) item.getItemMeta();
|
||||
if(texture == null && owner != null) {
|
||||
if(owner != null) {
|
||||
skullMeta.setOwner(owner);
|
||||
item.setItemMeta(skullMeta);
|
||||
return;
|
||||
}
|
||||
|
||||
if(texture != null){
|
||||
ServerVersion serverVersion = PlayerKits2.serverVersion;
|
||||
if(serverVersion.serverVersionGreaterEqualThan(serverVersion,ServerVersion.v1_20_R2)){
|
||||
UUID uuid = id != null ? UUID.fromString(id) : UUID.randomUUID();
|
||||
|
|
@ -163,10 +163,12 @@ public class ItemUtils {
|
|||
try {
|
||||
String decoded = new String(Base64.getDecoder().decode(texture));
|
||||
String decodedFormatted = decoded.replaceAll("\\s", "");
|
||||
int firstIndex = decodedFormatted.indexOf("\"SKIN\":{\"url\":")+15;
|
||||
int lastIndex = decodedFormatted.indexOf("\"",firstIndex+1);
|
||||
url = new URL(decodedFormatted.substring(firstIndex,lastIndex));
|
||||
} catch (MalformedURLException error) {
|
||||
JsonObject jsonObject = new Gson().fromJson(decodedFormatted, JsonObject.class);
|
||||
String urlText = jsonObject.get("textures").getAsJsonObject().get("SKIN")
|
||||
.getAsJsonObject().get("url").getAsString();
|
||||
|
||||
url = new URL(urlText);
|
||||
} catch (Exception error) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
|
@ -190,6 +192,7 @@ public class ItemUtils {
|
|||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.setItemMeta(skullMeta);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
main: pk.ajneb97.PlayerKits2
|
||||
version: 1.9.2
|
||||
version: 1.9.3
|
||||
name: PlayerKits2
|
||||
api-version: 1.13
|
||||
softdepend: [Vault,PlaceholderAPI]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue