SteamWar/MissileWars
Archiviert
13
0

Fix MWTeam.givePlayerItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-08-01 10:33:55 +02:00
Ursprung 8b945b0089
Commit f3f341d38e

Datei anzeigen

@ -53,7 +53,7 @@ public class MWTeam {
private final Location spawn;
private final int portalZ;
private final LinkedList<Player> players = new LinkedList<>();
private final LinkedList<Player> players = new LinkedList<>();
private final Set<Player> openInvitations = new HashSet<>();
MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) {
@ -61,7 +61,7 @@ public class MWTeam {
this.color = color;
this.spawn = spawn;
this.portalZ = portalZ;
if(FightScoreboard.getScoreboard().getTeam(teamName) == null)
if (FightScoreboard.getScoreboard().getTeam(teamName) == null)
sbteam = FightScoreboard.getScoreboard().registerNewTeam(teamName);
else
sbteam = FightScoreboard.getScoreboard().getTeam(teamName);
@ -94,22 +94,51 @@ public class MWTeam {
return 1_000_000;
}
private boolean hasUses(ItemStack itemStack) {
switch (itemStack.getType()) {
case WOODEN_AXE:
case STONE_AXE:
case IRON_AXE:
case GOLDEN_AXE:
case DIAMOND_AXE:
case NETHERITE_AXE:
// return true;
case WOODEN_SHOVEL:
case STONE_SHOVEL:
case IRON_SHOVEL:
case GOLDEN_SHOVEL:
case DIAMOND_SHOVEL:
case NETHERITE_SHOVEL:
// return true;
case WOODEN_PICKAXE:
case STONE_PICKAXE:
case IRON_PICKAXE:
case GOLDEN_PICKAXE:
case DIAMOND_PICKAXE:
case NETHERITE_PICKAXE:
return true;
default:
return false;
}
}
public void givePlayerItem(ItemStack item) {
if (players.isEmpty()) {
return;
}
if (players.isEmpty()) {
return;
}
Player p = players.removeFirst();
players.addLast(p);
Inventory inventory = p.getInventory();
for (int i = 0; i <= 35; i++) { // 35 is the last normal inventory slot
ItemStack itemStack = inventory.getItem(i);
if (itemStack != null && itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) {
if (itemStack == null) continue;
if (itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) {
itemStack.setAmount(itemStack.getAmount() + item.getAmount());
inventory.setItem(i, itemStack);
return;
}
if (itemStack != null && itemStack.getType() == item.getType() && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) {
if (hasUses(itemStack) && hasUses(item) && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) {
int uses = getUsesOfItem(itemStack) + getUsesOfItem(item);
ItemMeta itemMeta = itemStack.getItemMeta();
Damageable damageable = (Damageable) itemMeta;
@ -141,7 +170,7 @@ public class MWTeam {
return portalZ;
}
public Location getSpawn(){
public Location getSpawn() {
return spawn;
}
@ -202,7 +231,7 @@ public class MWTeam {
return MissileWars.getRedTeam();
}
public String getColorCode(){
public String getColorCode() {
return "§" + color.getChar();
}