mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-26 02:34:42 +02:00
Merge master 2.1.40
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.chat.McMMOChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -46,12 +47,14 @@ public abstract class ChatManager {
|
||||
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
|
||||
|
||||
//Find the people with permissions
|
||||
for(Player player : event.getPlugin().getServer().getOnlinePlayers())
|
||||
for(McMMOPlayer mcMMOPlayer : UserManager.getPlayers())
|
||||
{
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
//Check for toggled players
|
||||
if(UserManager.getPlayer(player).isPartyChatSpying())
|
||||
if(mcMMOPlayer.isPartyChatSpying())
|
||||
{
|
||||
Party adminParty = UserManager.getPlayer(player).getParty();
|
||||
Party adminParty = mcMMOPlayer.getParty();
|
||||
|
||||
//Only message admins not part of this party
|
||||
if(adminParty != null)
|
||||
|
@ -27,6 +27,7 @@ public class PlayerProfile {
|
||||
/* HUDs */
|
||||
private MobHealthbarType mobHealthbarType;
|
||||
private int scoreboardTipsShown;
|
||||
private int saveAttempts = 0;
|
||||
|
||||
/* Skill Data */
|
||||
private final Map<PrimarySkillType, Integer> skills = new HashMap<>(); // Skill & Level
|
||||
@ -34,9 +35,9 @@ public class PlayerProfile {
|
||||
private final Map<SuperAbilityType, Integer> abilityDATS = new HashMap<>(); // Ability & Cooldown
|
||||
private final Map<UniqueDataType, Integer> uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
|
||||
// Store previous XP gains for deminished returns
|
||||
private DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<>();
|
||||
private HashMap<PrimarySkillType, Float> rollingSkillsXp = new HashMap<>();
|
||||
// Store previous XP gains for diminished returns
|
||||
private DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<SkillXpGain>();
|
||||
private HashMap<PrimarySkillType, Float> rollingSkillsXp = new HashMap<PrimarySkillType, Float>();
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(String playerName) {
|
||||
@ -92,8 +93,13 @@ public class PlayerProfile {
|
||||
new PlayerProfileSaveTask(this).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
public void scheduleAsyncSaveDelay() {
|
||||
new PlayerProfileSaveTask(this).runTaskLaterAsynchronously(mcMMO.p, 20);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!changed || !loaded) {
|
||||
saveAttempts = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -102,8 +108,29 @@ public class PlayerProfile {
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||
|
||||
if (changed) {
|
||||
mcMMO.p.getLogger().warning("PlayerProfile saving failed for player: " + playerName + " " + uuid);
|
||||
mcMMO.p.getLogger().severe("PlayerProfile saving failed for player: " + playerName + " " + uuid);
|
||||
|
||||
if(saveAttempts > 0)
|
||||
{
|
||||
mcMMO.p.getLogger().severe("Attempted to save profile for player "+getPlayerName()
|
||||
+ " resulted in failure. "+saveAttempts+" have been made so far.");
|
||||
}
|
||||
|
||||
if(saveAttempts < 10)
|
||||
{
|
||||
saveAttempts++;
|
||||
scheduleAsyncSaveDelay();
|
||||
return;
|
||||
} else {
|
||||
mcMMO.p.getLogger().severe("mcMMO has failed to save the profile for "
|
||||
+getPlayerName()+" numerous times." +
|
||||
" mcMMO will now stop attempting to save this profile." +
|
||||
" Check your console for errors and inspect your DB for issues.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
saveAttempts = 0;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.skills.subskills.acrobatics;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.LimitedSizeList;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -32,15 +31,11 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Roll extends AcrobaticsSubSkill {
|
||||
protected HashMap<Player, LimitedSizeList> fallLocationMap;
|
||||
|
||||
|
||||
public Roll() {
|
||||
super("Roll", EventPriority.HIGHEST, SubSkillType.ACROBATICS_ROLL);
|
||||
if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
|
||||
fallLocationMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -287,12 +282,7 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
if(System.currentTimeMillis() < UserManager.getPlayer(player).getTeleportATS())
|
||||
return true;
|
||||
|
||||
if(fallLocationMap.get(player) == null)
|
||||
fallLocationMap.put(player, new LimitedSizeList(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getAcrobaticLocationLimit()));
|
||||
|
||||
LimitedSizeList fallLocations = fallLocationMap.get(player);
|
||||
|
||||
if(fallLocations.contains(getBlockLocation(player)))
|
||||
if(UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -423,16 +413,7 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
|
||||
public void addFallLocation(Player player)
|
||||
{
|
||||
if(!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
|
||||
return;
|
||||
|
||||
if(fallLocationMap.get(player) == null)
|
||||
fallLocationMap.put(player, new LimitedSizeList(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getAcrobaticLocationLimit()));
|
||||
|
||||
LimitedSizeList fallLocations = fallLocationMap.get(player);
|
||||
|
||||
Location loc = getBlockLocation(player);
|
||||
fallLocations.add(loc);
|
||||
UserManager.getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
|
||||
}
|
||||
|
||||
public Location getBlockLocation(Player player)
|
||||
|
@ -495,7 +495,8 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||
//Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick
|
||||
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60);
|
||||
|
||||
if (mcMMO.getConfigManager().getConfigMOTD().isEnableMOTD()) {
|
||||
Motd.displayAll(player);
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
private static final int MAX_TRIES = 5;
|
||||
private final Player player;
|
||||
private int attempt = 0;
|
||||
|
||||
@ -37,9 +36,6 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
// Increment attempt counter and try
|
||||
attempt++;
|
||||
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
||||
// If successful, schedule the apply
|
||||
if (profile.isLoaded()) {
|
||||
@ -47,14 +43,24 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've failed five times, give up
|
||||
if (attempt >= MAX_TRIES) {
|
||||
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + player.getName());
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.AdminFailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||
player.sendMessage(LocaleLoader.getString("Profile.Loading.Failure").split("\n"));
|
||||
return;
|
||||
// Print errors to console/logs if we're failing at least 2 times in a row to load the profile
|
||||
if (attempt >= 3)
|
||||
{
|
||||
//Log the error
|
||||
mcMMO.p.getLogger().severe(LocaleLoader.getString("Profile.Loading.FailureNotice",
|
||||
player.getName(), String.valueOf(attempt)));
|
||||
|
||||
//Notify the admins
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.FailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||
|
||||
//Notify the player
|
||||
player.sendMessage(LocaleLoader.getString("Profile.Loading.FailurePlayer", String.valueOf(attempt)).split("\n"));
|
||||
}
|
||||
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, 100 * attempt);
|
||||
|
||||
// Increment attempt counter and try
|
||||
attempt++;
|
||||
|
||||
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, 100);
|
||||
}
|
||||
|
||||
private class ApplySuccessfulProfile extends BukkitRunnable {
|
||||
@ -90,7 +96,6 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
player.sendMessage(LocaleLoader.getString("Profile.Loading.Success"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.skills.acrobatics;
|
||||
|
||||
import com.gmail.nossr50.datatypes.LimitedSizeList;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -15,6 +16,7 @@ import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -23,11 +25,26 @@ public class AcrobaticsManager extends SkillManager {
|
||||
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.ACROBATICS);
|
||||
rollXPInterval = (1000 * mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getRollXPGainCooldownSeconds());
|
||||
|
||||
//Save some memory if exploit prevention is off
|
||||
if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
|
||||
fallLocationMap = new LimitedSizeList(mcMMO.getConfigManager().getConfigExploitPrevention().getAcrobaticLocationLimit());
|
||||
}
|
||||
|
||||
private long rollXPCooldown = 0;
|
||||
private long rollXPInterval;
|
||||
private long rollXPIntervalLengthen = (1000 * 10); //10 Seconds
|
||||
private LimitedSizeList fallLocationMap;
|
||||
|
||||
public boolean hasFallenInLocationBefore(Location location)
|
||||
{
|
||||
return fallLocationMap.contains(location);
|
||||
}
|
||||
|
||||
public void addLocationToFallMap(Location location)
|
||||
{
|
||||
fallLocationMap.add(location);
|
||||
}
|
||||
|
||||
public boolean canGainRollXP()
|
||||
{
|
||||
|
@ -96,7 +96,11 @@ public final class UserManager {
|
||||
}
|
||||
|
||||
public static McMMOPlayer getPlayer(Player player) {
|
||||
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||
//Avoid Array Index out of bounds
|
||||
if(player.hasMetadata(mcMMO.playerDataKey))
|
||||
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
|
||||
|
Reference in New Issue
Block a user