mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-29 05:47:36 +01:00
Merge branch 'master' of https://git.lumine.io/mythiccraft/mmocore
This commit is contained in:
commit
8d416dbdef
BIN
lib/MMOLib.jar
BIN
lib/MMOLib.jar
Binary file not shown.
@ -352,7 +352,7 @@ public class MMOCore extends JavaPlugin {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
for (PlayerData loaded : PlayerData.getAll())
|
||||
dataProvider.getDataManager().saveData(loaded);
|
||||
if(loaded.isFullyLoaded()) dataProvider.getDataManager().saveData(loaded);
|
||||
|
||||
for (Guild guild : dataProvider.getGuildManager().getAll())
|
||||
dataProvider.getGuildManager().save(guild);
|
||||
@ -363,6 +363,7 @@ public class MMOCore extends JavaPlugin {
|
||||
|
||||
public void onDisable() {
|
||||
for (PlayerData data : PlayerData.getAll()) {
|
||||
if(!data.isFullyLoaded()) return;
|
||||
data.getQuestData().resetBossBar();
|
||||
dataProvider.getDataManager().saveData(data);
|
||||
}
|
||||
|
@ -5,8 +5,12 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.mmogroup.mmolib.UtilityMethods;
|
||||
import net.mmogroup.mmolib.api.condition.BlockCondition;
|
||||
import net.mmogroup.mmolib.api.condition.MMOCondition;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -24,6 +28,7 @@ public class BlockInfo {
|
||||
private final boolean vanillaDrops;
|
||||
private final List<Trigger> triggers = new ArrayList<>();
|
||||
private final RegenInfo regen;
|
||||
private final List<BlockCondition> conditions = new ArrayList<>();
|
||||
|
||||
/*
|
||||
* saved separately because MMOCore needs to display the experience gained,
|
||||
@ -56,6 +61,13 @@ public class BlockInfo {
|
||||
|
||||
Optional<Trigger> opt = triggers.stream().filter(trigger -> (trigger instanceof ExperienceTrigger)).findFirst();
|
||||
experience = (ExperienceTrigger) opt.orElse(null);
|
||||
|
||||
if(config.isList("conditions"))
|
||||
for(String key : config.getStringList("conditions")) {
|
||||
MMOCondition condition = UtilityMethods.getCondition(key);
|
||||
if(condition instanceof BlockCondition) conditions.add((BlockCondition) condition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean hasVanillaDrops() {
|
||||
@ -110,6 +122,13 @@ public class BlockInfo {
|
||||
return triggers;
|
||||
}
|
||||
|
||||
public boolean checkConditions(Block block) {
|
||||
for(BlockCondition condition : conditions)
|
||||
if(!condition.check(block)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class RegeneratingBlock {
|
||||
private final BlockData data;
|
||||
private final Location loc;
|
||||
|
@ -96,6 +96,8 @@ public class PlayerData extends OfflinePlayerData {
|
||||
public boolean nocd;
|
||||
public CombatRunnable combat;
|
||||
|
||||
private boolean fullyLoaded = false;
|
||||
|
||||
public PlayerData(MMOPlayerData mmoData) {
|
||||
super(mmoData.getUniqueId());
|
||||
|
||||
@ -581,6 +583,14 @@ public class PlayerData extends OfflinePlayerData {
|
||||
stellium = Math.max(0, Math.min(amount, getStats().getStat(StatType.MAX_STELLIUM)));
|
||||
}
|
||||
|
||||
public boolean isFullyLoaded() {
|
||||
return fullyLoaded;
|
||||
}
|
||||
|
||||
public void setFullyLoaded() {
|
||||
this.fullyLoaded = true;
|
||||
}
|
||||
|
||||
public boolean isCasting() {
|
||||
return skillCasting != null;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
|
||||
boolean temporaryBlock = MMOCore.plugin.mineManager.isTemporaryBlock(block);
|
||||
if (temporaryBlock && info == null) {
|
||||
if ((temporaryBlock && info == null) || !info.checkConditions(block)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class SpellCast implements Listener {
|
||||
? MMOCore.plugin.configManager.sneakingSwapAction
|
||||
: MMOCore.plugin.configManager.normalSwapAction;
|
||||
if(action != ConfigManager.SwapAction.SPELL_CAST || !playerData.isOnline()) return;
|
||||
if (event.getPlayer().equals(playerData.getPlayer()) && !player.isSneaking()) {
|
||||
if (event.getPlayer().equals(playerData.getPlayer())) {
|
||||
MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.SPELL_CAST_END);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(playerData.getPlayer());
|
||||
close();
|
||||
|
@ -47,8 +47,12 @@ public abstract class PlayerDataManager {
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
PlayerData loaded = PlayerData.get(uuid);
|
||||
if(!loaded.isOnline()) return;
|
||||
loadData(loaded);
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(loaded)));
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> {
|
||||
if(loaded.isOnline())
|
||||
Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(loaded));
|
||||
});
|
||||
loaded.getStats().updateStats();
|
||||
});
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
data.setFullyLoaded();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -249,7 +250,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
@Override
|
||||
public void remove(PlayerData data) {
|
||||
saveData(data);
|
||||
if(data.isFullyLoaded()) saveData(data);
|
||||
remove(data.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "Could not load class info '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
data.setFullyLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user