Proposing this as the system for the timeout. I havent test this yet though as my MMOCore is not builing properly.

This commit is contained in:
Rosenthalk0 2023-06-26 17:08:03 -05:00
parent 00f1581707
commit 22ee698d7c
3 changed files with 11 additions and 4 deletions

View File

@ -439,7 +439,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
}
public long getLastActivity(PlayerActivity activity) {
return this.lastActivity.getOrDefault(activity, 0l);
return this.lastActivity.getOrDefault(activity, 0L);
}
public long getActivityTimeOut(PlayerActivity activity) {
@ -1062,6 +1062,10 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
return true;
}
public boolean isCastingTimeoutExpired(){
return isCasting() && System.currentTimeMillis() - getLastActivity(PlayerActivity.CAST_SKILL) > (MMOCore.plugin.configManager.castingTimeoutTime * 1000L) && MMOCore.plugin.configManager.castingTimeoutTime > 0;
}
public void displayActionBar(String message) {
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE);
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));

View File

@ -34,11 +34,10 @@ public class ConfigManager {
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
public double lootChestsChanceWeight, dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange, pvpModeToggleOnCooldown, pvpModeToggleOffCooldown, pvpModeCombatCooldown,
pvpModeCombatTimeout, pvpModeInvulnerabilityTimeRegionChange, pvpModeInvulnerabilityTimeCommand, pvpModeRegionEnterCooldown, pvpModeRegionLeaveCooldown;
public int maxPartyLevelDifference, maxSkillSlots, minCombatLevel, maxCombatLevelDifference, skillTreeScrollStepX, skillTreeScrollStepY;
public int maxPartyLevelDifference, maxSkillSlots, minCombatLevel, maxCombatLevelDifference, skillTreeScrollStepX, skillTreeScrollStepY, castingTimeoutTime;
public final List<EntityDamageEvent.DamageCause> combatLogDamageCauses = new ArrayList<>();
private final FileConfiguration messages;
/*
* The instance must be created after the other managers since all it does
* is to update them based on the config except for the classes which are
@ -124,6 +123,10 @@ public class ConfigManager {
lootChestExpireTime = Math.max(MMOCore.plugin.getConfig().getInt("loot-chests.chest-expire-time"), 1) * 20;
lootChestPlayerCooldown = (long) MMOCore.plugin.getConfig().getDouble("player-cooldown") * 1000L;
globalSkillCooldown = MMOCore.plugin.getConfig().getLong("global-skill-cooldown") * 50;
//Timeout for casting
castingTimeoutTime = MMOCore.plugin.getConfig().getInt("skill-casting.timeout",0);
noSkillBoundPlaceholder = getSimpleMessage("no-skill-placeholder").message();
lootChestsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.loot-chests");
dropItemsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.drop-items");

View File

@ -39,7 +39,7 @@ public abstract class SkillCastingInstance extends BukkitRunnable implements Lis
@Override
public void run() {
if (!caster.isOnline() || caster.getPlayer().isDead()) {
if (!caster.isOnline() || caster.getPlayer().isDead() || caster.isCastingTimeoutExpired()) {
caster.leaveSkillCasting();
return;
}