This commit is contained in:
Ka0rX 2023-06-25 10:10:21 +01:00
commit c0f3ac0638
6 changed files with 81 additions and 17 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;
}
}