Encumbered function update & debug removed

This commit is contained in:
Roch Blonndiaux 2023-01-26 12:32:23 +01:00
parent fc2222f0c8
commit 4effb830cf
4 changed files with 6 additions and 25 deletions

View File

@ -54,7 +54,6 @@ public class PlayerData {
private final Map<PotionEffectType, PotionEffect> permanentEffects = new HashMap<>();
private final Set<ParticleRunnable> itemParticles = new HashSet<>();
private ParticleRunnable overridingItemParticles = null;
private boolean encumbered = false;
@Nullable
private SetBonuses setBonuses = null;
private final PlayerStats stats;
@ -193,7 +192,7 @@ public class PlayerData {
* Updates the encumbered boolean, this way it can be
* cached and used in the updateEffects() method
*/
encumbered = isEncumbered();
// encumbered = isEncumbered();
// Find all the items the player can actually use
for (EquippedItem item : MMOItems.plugin.getInventory().inventory(getPlayer())) {
@ -318,14 +317,6 @@ public class PlayerData {
// inventory.offhand = getPlayer().getInventory().getItemInOffHand();
}
public void updateStats() {
// Permanent effects
permanentEffects.values().forEach(effect -> getPlayer().addPotionEffect(effect));
// Two handed slowness
if (encumbered)
getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 1, true, false));
}
public PlayerMMOInventory getInventory() {
return inventory;
@ -439,11 +430,6 @@ public class PlayerData {
this.overridingItemParticles = overridingItemParticles;
}
@ApiStatus.Internal
public void refreshEncumberedValue() {
this.encumbered = isEncumbered();
}
@ApiStatus.Internal
public @NotNull Set<String> permissions() {
return permissions;

View File

@ -47,7 +47,6 @@ public abstract class EquippedItem {
public void cacheItem() {
Validate.isTrue(cached == null, "MMOItem has already been cached");
cached = new VolatileMMOItem(item);
MMOItems.log("Cached item " + cached.getType().getName() + " in slot " + slot);
}
public NBTItem getNBT() {

View File

@ -23,6 +23,7 @@ import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -71,9 +72,6 @@ public class PlayerInventoryHandler implements Runnable {
if (item.getSlot().equals(EquipmentSlot.ARMOR))
armorChanged.set(true);
// TODO: remove the following line
MMOItems.log(String.format("Slot #%d: %s -> %s", slot, oldItem == null ? "AIR" : oldItem.getId(), newItem == null ? "AIR" : newItem.getId()));
// Process old item
this.processOldItem(slot, oldItem);
@ -86,9 +84,6 @@ public class PlayerInventoryHandler implements Runnable {
// Process old item sets
this.processOldItemSets();
// Refresh player data
this.data.refreshEncumberedValue();
// Call Bukkit event
Bukkit.getPluginManager().callEvent(new MMOInventoryRefreshEvent(inventory.equipped(), this.data.getPlayer(), this.data));
@ -96,6 +91,10 @@ public class PlayerInventoryHandler implements Runnable {
this.processNewItemSets(newImage);
}
// Check if the player is encumbered
if (this.data.isEncumbered())
this.player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 1, true, false));
// Update stats from external plugins
MMOItems.plugin.getRPG().refreshStats(this.data);
@ -199,7 +198,6 @@ public class PlayerInventoryHandler implements Runnable {
// Apply the bonuses
if (bonuses == null)
return;
MMOItems.log("Applying bonuses... Abilities: " + bonuses.getAbilities().size() + " Particles: " + bonuses.getParticles().size() + " Potion effects: " + bonuses.getPotionEffects().size() + " Permissions: " + bonuses.getPermissions().size());
// Stats
final ItemSet.SetBonuses finalBonuses = bonuses;

View File

@ -28,7 +28,5 @@ public class MMOItemsBukkit {
if (plugin.getConfig().getBoolean("dropped-items.tier-glow") || plugin.getConfig().getBoolean("dropped-items.hints"))
Bukkit.getPluginManager().registerEvents(new DroppedItems(plugin.getConfig().getConfigurationSection("dropped-items")), plugin);
Bukkit.getScheduler().runTaskTimer(plugin, () -> Bukkit.getOnlinePlayers().forEach(player -> PlayerData.get(player).updateStats()), 100, 20);
}
}