Skip to content

Commit

Permalink
Merge branch 'dev' into release/2.0.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakllp committed Jul 18, 2021
2 parents bbcdfdf + b100da1 commit 29c94ab
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tommytony</groupId>
<artifactId>war</artifactId>
<version>2.9.0</version>
<version>2.9.1</version>
<packaging>jar</packaging>
<name>War</name>
<url>http://war.tommytony.com</url>
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/tommytony/war/War.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public void loadWar() {
warzoneDefaultConfig.put(WarzoneConfig.PREPTIME, 0);
warzoneDefaultConfig.put(WarzoneConfig.DISABLECOOLDOWN, false);
warzoneDefaultConfig.put(WarzoneConfig.SWORDBLOCKING, false);
warzoneDefaultConfig.put(WarzoneConfig.RAPIDDAMAGE, true);
warzoneDefaultConfig.put(WarzoneConfig.RAPIDDAMAGE, false);
warzoneDefaultConfig.put(WarzoneConfig.GAMEMODE, "SURVIVAL");

teamDefaultConfig.put(TeamConfig.FLAGMUSTBEHOME, true);
Expand Down Expand Up @@ -439,14 +439,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
* @param loadout
* the hashmap to save to
*/
private void inventoryToLoadout(PlayerInventory inv, HashMap<Integer, ItemStack> loadout) {
private void inventoryToLoadout(PlayerInventory inv, HashMap<Integer, ItemStack> loadout) { //MARK Loadout Shit
loadout.clear();
int i = 0;
for (ItemStack stack : inv.getStorageContents()) {
if (stack != null && stack.getType() != Material.AIR) {
loadout.put(i, stack.clone());
i++;
}
i++;
}
if (inv.getBoots() != null && inv.getBoots().getType() != Material.AIR) {
loadout.put(100, inv.getBoots().clone());
Expand All @@ -460,6 +460,9 @@ private void inventoryToLoadout(PlayerInventory inv, HashMap<Integer, ItemStack>
if (inv.getHelmet() != null && inv.getHelmet().getType() != Material.AIR) {
loadout.put(103, inv.getHelmet().clone());
}
if (inv.getItemInOffHand() != null && inv.getItemInOffHand().getType() != Material.AIR) {
loadout.put(40, inv.getItemInOffHand().clone());
}
}

public void safelyEnchant(ItemStack target, Enchantment enchantment, int level) {
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/tommytony/war/Warzone.java
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,6 @@ private void resetInventory(Team team, Player player, Map<Integer, ItemStack> lo
// Reset inventory to loadout
PlayerInventory playerInv = player.getInventory();
playerInv.clear();
playerInv.clear(playerInv.getSize());
playerInv.clear(playerInv.getSize() + 1);
playerInv.clear(playerInv.getSize() + 2);
playerInv.clear(playerInv.getSize() + 3); // helmet/blockHead

Loadout banned = Loadout.getLoadout(team.getInventories().resolveNewLoadouts(), "banned");
Set<Material> bannedMaterials = new HashSet<Material>();
Expand All @@ -651,7 +647,7 @@ private void resetInventory(Team team, Player player, Map<Integer, ItemStack> lo
} else if (slot == 103) {
playerInv.setHelmet(item.clone());
} else {
playerInv.addItem(item.clone());
playerInv.setItem(slot, item.clone());
}
}
if (this.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/com/tommytony/war/event/SwordBlockingListener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.tommytony.war.event;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
Expand All @@ -24,6 +26,7 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;

import com.tommytony.war.War;
Expand Down Expand Up @@ -71,13 +74,19 @@ public void onRightClick(PlayerInteractEvent e){
if(!p.isBlocking()){
ItemStack item = e.getItem();

if(!isHoldingSword(item.getType()) || hasShield(p)) return;
if(!isHoldingSword(item.getType()) || hasNormShield(p)) return;

PlayerInventory inv = p.getInventory();

storedOffhandItems.put(id, inv.getItemInOffHand());

inv.setItemInOffHand(SHIELD);

ItemStack shield = SHIELD.clone();
ItemMeta meta = shield.getItemMeta();
List<String> lore = new ArrayList<String>();
lore.add("War-Shield");
meta.setLore(lore);
shield.setItemMeta(meta);
inv.setItemInOffHand(shield);
}

scheduleRestore(p);
Expand Down Expand Up @@ -218,9 +227,14 @@ private boolean isBlocking(UUID uuid){
}

private boolean hasShield(Player p){
ItemStack item = p.getInventory().getItemInOffHand();
return item.getType() == Material.SHIELD && item.getItemMeta().getLore() != null && item.getItemMeta().getLore().contains("War-Shield");
}

private boolean hasNormShield(Player p){
return p.getInventory().getItemInOffHand().getType() == Material.SHIELD;
}

private boolean isHoldingSword(Material mat){
return mat.toString().endsWith("_SWORD");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/messages_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ zone.flagreturn.spawn = Du musst die gegnerische Flagge bei deinem Team Spawn si
zone.leavenotice = Benutze /leave um die Zone zu verlassen.
zone.lifepool.empty = Team {0}s Leben sind leer. Ein Tod mehr und sie verlieren den Kampf.
zone.loadout.equip = Mit {0} ausger\u00fcstet (Schleiche zum wechseln).
zone.loadout.reenter = Wechsle die Ausr\u00fcstung nach dem Verlassen des Spawns.
zone.loadout.reenter = Wechseln der Ausr\u00fcstung nach dem Verlassen des Spawns nicht möglich.
zone.monument.badblock = Du musst ein Monument mit einem Block in deiner Teamfarbe sichern. Bekomme einem von deinem Team Spawn.
zone.monument.capture = Monument {0} wurde gesichert von Team {1}.
zone.monument.lose = Team {0} verliert die Kontrolle von Monument {1}.
Expand Down

0 comments on commit 29c94ab

Please sign in to comment.