Merge branch 'master' into casting-events-enter-exit

# Conflicts:
#	MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/PlayerEnterCastingModeEvent.java
#	MMOCore-API/src/main/java/net/Indyuce/mmocore/api/event/PlayerExitCastingModeEvent.java
#	MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java
#	MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/cast/listener/KeyCombos.java
#	MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/cast/listener/SkillBar.java
#	MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/cast/listener/SkillScroller.java
This commit is contained in:
Ka0rX 2023-06-25 10:23:32 +01:00
commit 77ecc005b4
7 changed files with 87 additions and 25 deletions

View File

@ -6,12 +6,12 @@ Things can you CANNOT do:
- Issue a refund on PayPal without our explicit permission, as this is a digital good.
- Redistribute, sell or give an official/modified version of the plugin (with or without any type of counterpart) to anyone else.
- Modify and compile the project source code to bypass an anti-piracy protection.
- Download, compile, decompile or use the plugin on a production server without purchasing a license.
- Download, compile, decompile or use the plugin on any server without purchasing a license.
Things can you CAN do when purchasing the plugin:
- Download and decompile the plugin file.
- Fork and modify the project source code to meet your production server's needs.
- Use it on ONE production server or network (= proxy-connected servers) at a time.
- Use it on ONE production server or network (= proxy-connected servers) and one private test server at a time.
You may propose a merge request, under the terms that you grant full rights to us using any pushed code.

View File

@ -275,25 +275,12 @@ public class MMOCore extends JavaPlugin {
@Override
public void onDisable() {
// Executes all the pending asynchronous task (like saving the playerData)
Bukkit.getScheduler().getPendingTasks().forEach(worker -> {
if (worker.getOwner().equals(this)) {
((Runnable) worker).run();
}
});
// Save player data
for (PlayerData data : PlayerData.getAll())
if (data.isSynchronized()) {
data.close();
dataProvider.getDataManager().getDataHandler().saveData(data, true);
}
// Save guild info
for (Guild guild : dataProvider.getGuildManager().getAll())
dataProvider.getGuildManager().save(guild);
// Close MySQL data provider (memory leaks)
playerDataManager.saveAll(false);
playerDataManager.getDataHandler().close();
// Reset active blocks

View File

@ -119,6 +119,12 @@ public class DefaultMMOLoader extends MMOLoader {
if (config.getKey().equals("permission"))
return new PermissionCondition(config);
if (config.getKey().equals("weather"))
return new WeatherCondition(config);
if (config.getKey().equals("time"))
return new TimeCondition(config);
return null;
}

View File

@ -92,7 +92,7 @@ public class ExportDataTreeNode extends CommandTreeNode {
MMOCore.plugin.dataProvider.getDataManager().getDataHandler().loadData(offlinePlayerData);
// Player data is loaded, now it gets saved through SQL
sqlHandler.saveData(offlinePlayerData, true);
sqlHandler.saveData(offlinePlayerData, false);
} catch (RuntimeException exception) {
errorCount++;
exception.printStackTrace();

View File

@ -0,0 +1,37 @@
package net.Indyuce.mmocore.loot.chest.condition;
import io.lumine.mythic.lib.api.MMOLineConfig;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
public class TimeCondition extends Condition {
private final int min;
private final int max;
public TimeCondition(MMOLineConfig config) {
super(config);
Validate.isTrue(config.contains("min"));
Validate.isTrue(config.contains("max"));
min = config.getInt("min");
max = config.getInt("max");
}
@Override
public boolean isMet(ConditionInstance entity) {
if (entity.getEntity() instanceof Player player) {
long time = player.getWorld().getTime();
if (min < max) {
return time > min && time < max;
} else {
// Allows for wrapping times, such as min=20000 max=6000
return time > min || time < max;
}
}
return false;
}
}

View File

@ -0,0 +1,34 @@
package net.Indyuce.mmocore.loot.chest.condition;
import io.lumine.mythic.lib.api.MMOLineConfig;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
public class WeatherCondition extends Condition {
private final String condition;
public WeatherCondition(MMOLineConfig config) {
super(config);
Validate.isTrue(config.contains("condition"));
condition = config.getString("condition");
}
@Override
public boolean isMet(ConditionInstance entity) {
if (entity.getEntity() instanceof Player player) {
boolean isClear = player.getWorld().isClearWeather();
boolean hasStorm = player.getWorld().hasStorm();
if (condition.equalsIgnoreCase("clear")) {
return isClear;
} else if (condition.equalsIgnoreCase("stormy")) {
return hasStorm;
}
}
return false;
}
}

View File

@ -71,7 +71,7 @@ public class KeyCombos implements SkillCastingListener {
public void whenPressingKey(PlayerKeyPressEvent event) {
PlayerData playerData = event.getData();
Player player = playerData.getPlayer();
if(player.getGameMode()== GameMode.CREATIVE&&!MMOCore.plugin.configManager.canCreativeCast)
if (player.getGameMode() == GameMode.CREATIVE && !MMOCore.plugin.configManager.canCreativeCast)
return;
// Start combo when there is an initializer key
@ -82,9 +82,9 @@ public class KeyCombos implements SkillCastingListener {
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
// Start combo
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData))) {
if (beginComboSound != null) beginComboSound.playTo(player);
}
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData)) && beginComboSound != null)
beginComboSound.playTo(player);
}
return;
}
@ -99,10 +99,8 @@ public class KeyCombos implements SkillCastingListener {
final @NotNull ComboMap comboMap = Objects.requireNonNullElse(playerData.getProfess().getComboMap(), this.comboMap);
if (comboMap.isComboStart(event.getPressed())) {
casting = new CustomSkillCastingInstance(playerData);
if (!playerData.setSkillCasting(casting)) {
return;
}
if (beginComboSound != null) beginComboSound.playTo(player);
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData)) && beginComboSound != null)
beginComboSound.playTo(player);
}
}