9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00

code clean up

This commit is contained in:
XiaoMoMi
2023-09-22 19:45:39 +08:00
parent 2f4bf76f33
commit c5e6efdb5f
16 changed files with 20 additions and 28 deletions

View File

@@ -22,7 +22,6 @@ import net.momirealms.customfishing.api.data.PlayerData;
import net.momirealms.customfishing.api.mechanic.bag.FishingBagHolder;
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
import java.io.Serializable;
import java.util.UUID;
public interface OfflineUser {

View File

@@ -23,15 +23,10 @@ import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.mechanic.game.GameInstance;
import net.momirealms.customfishing.api.mechanic.game.GameSettings;
import net.momirealms.customfishing.api.mechanic.game.GamingPlayer;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
public interface FishingManager {

View File

@@ -25,7 +25,6 @@ import net.momirealms.customfishing.api.mechanic.game.GameInstance;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Optional;
public interface GameManager {

View File

@@ -170,7 +170,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager, Listener {
if (replacer == null) {
String custom = customPlaceholderMap.get(papi);
if (custom != null) {
replacer = setPlaceholders(player, custom);
replacer = setPlaceholders(player, parse(player, custom, placeholders));
}
}
if (replacer != null) {

View File

@@ -23,8 +23,6 @@ import net.momirealms.customfishing.api.integration.SeasonInterface;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class CustomCropsSeasonImpl implements SeasonInterface {
private final CustomCropsAPI customCropsAPI;

View File

@@ -461,7 +461,7 @@ public class BlockManagerImpl implements BlockManager, Listener {
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
if (entry.getValue() instanceof ConfigurationSection inner) {
String item = inner.getString("item");
Pair<Integer, Integer> amountPair = ConfigUtils.splitStringIntegerArgs(inner.getString("amount","1~1"));
Pair<Integer, Integer> amountPair = ConfigUtils.splitStringIntegerArgs(inner.getString("amount","1~1"), "~");
double chance = inner.getDouble("chance", 1);
tempChanceList.add(Tuple.of(chance, item, amountPair));
}

View File

@@ -156,7 +156,9 @@ public class CompetitionManagerImpl implements CompetitionManager {
CompetitionConfig competitionConfig = builder.build();
List<Pair<Integer, Integer>> timePairs = section.getStringList("start-time")
.stream().map(ConfigUtils::splitStringIntegerArgs).toList();
.stream().map(it -> {
return ConfigUtils.splitStringIntegerArgs(it, ":");
}).toList();
List<Integer> weekdays = section.getIntegerList("start-weekday");
if (weekdays.size() == 0) {
weekdays.addAll(List.of(1,2,3,4,5,6,7));

View File

@@ -56,7 +56,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class FishingManagerImpl implements Listener, FishingManager {

View File

@@ -18,7 +18,6 @@
package net.momirealms.customfishing.mechanic.requirement;
import net.momirealms.customfishing.api.common.Pair;
import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.mechanic.loot.WeightModifier;
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
import org.bukkit.entity.Player;

View File

@@ -331,7 +331,7 @@ public class RequirementManagerImpl implements RequirementManager {
private void registerTimeRequirement() {
registerRequirement("time", (args, actions, advanced) -> {
List<Pair<Integer, Integer>> timePairs = ConfigUtils.stringListArgs(args).stream().map(ConfigUtils::splitStringIntegerArgs).toList();
List<Pair<Integer, Integer>> timePairs = ConfigUtils.stringListArgs(args).stream().map(it -> ConfigUtils.splitStringIntegerArgs(it, "~")).toList();
return condition -> {
long time = condition.getLocation().getWorld().getTime();
for (Pair<Integer, Integer> pair : timePairs)
@@ -409,7 +409,7 @@ public class RequirementManagerImpl implements RequirementManager {
private void registerYRequirement() {
registerRequirement("ypos", (args, actions, advanced) -> {
List<Pair<Integer, Integer>> timePairs = ConfigUtils.stringListArgs(args).stream().map(ConfigUtils::splitStringIntegerArgs).toList();
List<Pair<Integer, Integer>> timePairs = ConfigUtils.stringListArgs(args).stream().map(it -> ConfigUtils.splitStringIntegerArgs(it, "~")).toList();
return condition -> {
int y = condition.getLocation().getBlockY();
for (Pair<Integer, Integer> pair : timePairs)

View File

@@ -24,7 +24,6 @@ import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.mechanic.effect.EffectCarrier;
import net.momirealms.customfishing.api.mechanic.totem.TotemConfig;
import net.momirealms.customfishing.api.mechanic.totem.TotemParticle;
import net.momirealms.customfishing.mechanic.totem.particle.ParticleSetting;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import org.bukkit.Location;

View File

@@ -28,13 +28,13 @@ import net.momirealms.customfishing.api.mechanic.condition.Condition;
import net.momirealms.customfishing.api.mechanic.effect.EffectCarrier;
import net.momirealms.customfishing.api.mechanic.totem.TotemConfig;
import net.momirealms.customfishing.api.mechanic.totem.TotemModel;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.api.mechanic.totem.block.TotemBlock;
import net.momirealms.customfishing.api.mechanic.totem.block.property.AxisImpl;
import net.momirealms.customfishing.api.mechanic.totem.block.property.FaceImpl;
import net.momirealms.customfishing.api.mechanic.totem.block.property.HalfImpl;
import net.momirealms.customfishing.api.mechanic.totem.block.property.TotemBlockProperty;
import net.momirealms.customfishing.api.mechanic.totem.block.type.TypeCondition;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.mechanic.totem.particle.DustParticleSetting;
import net.momirealms.customfishing.mechanic.totem.particle.ParticleSetting;
import net.momirealms.customfishing.util.LocationUtils;

View File

@@ -41,9 +41,9 @@ public class SchedulerImpl implements Scheduler {
this.plugin = plugin;
this.syncScheduler = plugin.getVersionManager().isFolia() ?
new FoliaSchedulerImpl(plugin) : new BukkitSchedulerImpl(plugin);
this.schedule = new ScheduledThreadPoolExecutor(4);
this.schedule.setMaximumPoolSize(4);
this.schedule.setKeepAliveTime(10, TimeUnit.SECONDS);
this.schedule = new ScheduledThreadPoolExecutor(1);
this.schedule.setMaximumPoolSize(1);
this.schedule.setKeepAliveTime(30, TimeUnit.SECONDS);
this.schedule.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
}

View File

@@ -27,7 +27,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import redis.clients.jedis.*;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.resps.Tuple;
import java.nio.charset.StandardCharsets;
import java.time.Duration;

View File

@@ -66,8 +66,8 @@ public class ConfigUtils {
* @param value The input string
* @return A Pair of integers
*/
public static Pair<Integer, Integer> splitStringIntegerArgs(String value) {
String[] split = value.split("~");
public static Pair<Integer, Integer> splitStringIntegerArgs(String value, String regex) {
String[] split = value.split(regex);
return Pair.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
}

View File

@@ -136,9 +136,9 @@ other-settings:
thread-pool-settings:
# The size of the core Thread pool, that is, the size of the Thread pool when there is no task to execute
# Increase the size of corePoolSize when you are running a large server with many players fishing at the same time
corePoolSize: 8
corePoolSize: 4
# The maximum number of threads allowed to be created in the Thread pool. The current number of threads in the Thread pool will not exceed this value
maximumPoolSize: 16
maximumPoolSize: 4
# If a thread is idle for more than this attribute value, it will exit due to timeout
keepAliveTime: 30
@@ -160,14 +160,13 @@ other-settings:
# CustomFishing supports using items from other plugins
# If items share the same id, they would inherit the effects
item-detection-order:
# - Oraxen
# - ItemsAdder
- CustomFishing
- vanilla
block-detection-order:
- vanilla
# Custom durability format
custom-durability-format:
- ''
- '<gray>Durability</gray><white>: {dur} <gray>/</gray> {max}</white>'