Skip to content

Commit

Permalink
update local branch
Browse files Browse the repository at this point in the history
  • Loading branch information
SrBedrock committed Aug 14, 2024
2 parents 7f99970 + 417ce9e commit 4ea7a49
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
Expand Down Expand Up @@ -163,7 +163,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.12.0-SNAPSHOT</version>
<version>2.13.2</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
Expand All @@ -184,4 +184,4 @@
<url>https://repo.roinujnosde.me/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class DatabaseManager {
private Connection connection;

private final Map<String, GroupData> groups = new HashMap<>();
private final Set<Warrior> warriors = new HashSet<>();
private final Map<UUID, Warrior> warriors = new HashMap<>();
private final List<Winners> winners = new ArrayList<>();

private enum CountType {
Expand Down Expand Up @@ -315,24 +315,17 @@ public GroupData getGroupData(@NotNull String id) {

@NotNull
public Warrior getWarrior(@NotNull OfflinePlayer player) {
UUID uuid = player.getUniqueId();
for (Warrior warrior : warriors) {
if (warrior.toPlayer().getUniqueId().equals(uuid)) {
if (player instanceof Player) {
warrior.setOnlinePlayer((Player) player);
}
return warrior;
}
}

Warrior warrior = new Warrior(player, plugin::getGroupManager);
warriors.add(warrior);
return warrior;
return getWarrior(player.getUniqueId());
}

@NotNull
public Warrior getWarrior(@NotNull UUID uuid) {
return getWarrior(Bukkit.getOfflinePlayer(uuid));
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
Warrior warrior = warriors.computeIfAbsent(uuid, (id) -> new Warrior(offlinePlayer, plugin::getGroupManager));
if (offlinePlayer instanceof Player) {
warrior.setOnlinePlayer((Player) offlinePlayer);
}
return warrior;
}

private void loopThroughGroups() {
Expand Down Expand Up @@ -390,7 +383,7 @@ private void loopThroughWarriors() {

Warrior warrior = new Warrior(player, plugin::getGroupManager, playerData.get(CountType.KILLS),
playerData.get(CountType.DEATHS), playerData.get(CountType.VICTORIES));
warriors.add(warrior);
warriors.put(warrior.getUniqueId(), warrior);
}


Expand Down Expand Up @@ -562,7 +555,7 @@ public Winners getWinners(Date date) {
}

public Set<Warrior> getWarriors() {
return Collections.unmodifiableSet(warriors);
return new HashSet<>(warriors.values());
}

public Map<String, GroupData> getGroups() {
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/me/roinujnosde/titansbattle/types/Kit.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.roinujnosde.titansbattle.types;

import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.iface.ReadWriteItemNBT;

import org.bukkit.Material;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
Expand All @@ -12,6 +14,7 @@

import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;

@SerializableAs("kit")
public class Kit implements ConfigurationSerializable {
Expand Down Expand Up @@ -138,18 +141,22 @@ private ItemStack getItem(Object object) {
return clone((ItemStack) object);
}

private void applyNBTTag(ItemStack item) {
NBT.modify(item, (Consumer<ReadWriteItemNBT>) nbtItem -> nbtItem.setBoolean(NBT_TAG, true));
}

private ItemStack clone(ItemStack item) {
if (item != null && item.getType() != Material.AIR) {
item = item.clone();
new NBTItem(item, true).setBoolean(NBT_TAG, true);
applyNBTTag(item);
}
return item;
}

private void setNBTTag(ItemStack[] items) {
for (ItemStack item : items) {
if (item != null && item.getType() != Material.AIR) {
new NBTItem(item, true).setBoolean(NBT_TAG, true);
applyNBTTag(item);
}
}
}
Expand Down

0 comments on commit 4ea7a49

Please sign in to comment.