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