mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-21 16:09:34 +00:00
code clean up
This commit is contained in:
@@ -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.bag.FishingBagHolder;
|
||||||
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
|
import net.momirealms.customfishing.api.mechanic.statistic.Statistics;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface OfflineUser {
|
public interface OfflineUser {
|
||||||
|
|||||||
@@ -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.GameInstance;
|
||||||
import net.momirealms.customfishing.api.mechanic.game.GameSettings;
|
import net.momirealms.customfishing.api.mechanic.game.GameSettings;
|
||||||
import net.momirealms.customfishing.api.mechanic.game.GamingPlayer;
|
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.FishHook;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface FishingManager {
|
public interface FishingManager {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import net.momirealms.customfishing.api.mechanic.game.GameInstance;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface GameManager {
|
public interface GameManager {
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager, Listener {
|
|||||||
if (replacer == null) {
|
if (replacer == null) {
|
||||||
String custom = customPlaceholderMap.get(papi);
|
String custom = customPlaceholderMap.get(papi);
|
||||||
if (custom != null) {
|
if (custom != null) {
|
||||||
replacer = setPlaceholders(player, custom);
|
replacer = setPlaceholders(player, parse(player, custom, placeholders));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (replacer != null) {
|
if (replacer != null) {
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import net.momirealms.customfishing.api.integration.SeasonInterface;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class CustomCropsSeasonImpl implements SeasonInterface {
|
public class CustomCropsSeasonImpl implements SeasonInterface {
|
||||||
|
|
||||||
private final CustomCropsAPI customCropsAPI;
|
private final CustomCropsAPI customCropsAPI;
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ public class BlockManagerImpl implements BlockManager, Listener {
|
|||||||
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
|
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
|
||||||
if (entry.getValue() instanceof ConfigurationSection inner) {
|
if (entry.getValue() instanceof ConfigurationSection inner) {
|
||||||
String item = inner.getString("item");
|
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);
|
double chance = inner.getDouble("chance", 1);
|
||||||
tempChanceList.add(Tuple.of(chance, item, amountPair));
|
tempChanceList.add(Tuple.of(chance, item, amountPair));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,9 @@ public class CompetitionManagerImpl implements CompetitionManager {
|
|||||||
|
|
||||||
CompetitionConfig competitionConfig = builder.build();
|
CompetitionConfig competitionConfig = builder.build();
|
||||||
List<Pair<Integer, Integer>> timePairs = section.getStringList("start-time")
|
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");
|
List<Integer> weekdays = section.getIntegerList("start-weekday");
|
||||||
if (weekdays.size() == 0) {
|
if (weekdays.size() == 0) {
|
||||||
weekdays.addAll(List.of(1,2,3,4,5,6,7));
|
weekdays.addAll(List.of(1,2,3,4,5,6,7));
|
||||||
|
|||||||
@@ -56,7 +56,10 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class FishingManagerImpl implements Listener, FishingManager {
|
public class FishingManagerImpl implements Listener, FishingManager {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package net.momirealms.customfishing.mechanic.requirement;
|
package net.momirealms.customfishing.mechanic.requirement;
|
||||||
|
|
||||||
import net.momirealms.customfishing.api.common.Pair;
|
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.loot.WeightModifier;
|
||||||
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ public class RequirementManagerImpl implements RequirementManager {
|
|||||||
|
|
||||||
private void registerTimeRequirement() {
|
private void registerTimeRequirement() {
|
||||||
registerRequirement("time", (args, actions, advanced) -> {
|
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 -> {
|
return condition -> {
|
||||||
long time = condition.getLocation().getWorld().getTime();
|
long time = condition.getLocation().getWorld().getTime();
|
||||||
for (Pair<Integer, Integer> pair : timePairs)
|
for (Pair<Integer, Integer> pair : timePairs)
|
||||||
@@ -409,7 +409,7 @@ public class RequirementManagerImpl implements RequirementManager {
|
|||||||
|
|
||||||
private void registerYRequirement() {
|
private void registerYRequirement() {
|
||||||
registerRequirement("ypos", (args, actions, advanced) -> {
|
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 -> {
|
return condition -> {
|
||||||
int y = condition.getLocation().getBlockY();
|
int y = condition.getLocation().getBlockY();
|
||||||
for (Pair<Integer, Integer> pair : timePairs)
|
for (Pair<Integer, Integer> pair : timePairs)
|
||||||
|
|||||||
@@ -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.effect.EffectCarrier;
|
||||||
import net.momirealms.customfishing.api.mechanic.totem.TotemConfig;
|
import net.momirealms.customfishing.api.mechanic.totem.TotemConfig;
|
||||||
import net.momirealms.customfishing.api.mechanic.totem.TotemParticle;
|
import net.momirealms.customfishing.api.mechanic.totem.TotemParticle;
|
||||||
import net.momirealms.customfishing.mechanic.totem.particle.ParticleSetting;
|
|
||||||
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
import net.momirealms.customfishing.api.scheduler.CancellableTask;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|||||||
@@ -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.effect.EffectCarrier;
|
||||||
import net.momirealms.customfishing.api.mechanic.totem.TotemConfig;
|
import net.momirealms.customfishing.api.mechanic.totem.TotemConfig;
|
||||||
import net.momirealms.customfishing.api.mechanic.totem.TotemModel;
|
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.TotemBlock;
|
||||||
import net.momirealms.customfishing.api.mechanic.totem.block.property.AxisImpl;
|
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.FaceImpl;
|
||||||
import net.momirealms.customfishing.api.mechanic.totem.block.property.HalfImpl;
|
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.property.TotemBlockProperty;
|
||||||
import net.momirealms.customfishing.api.mechanic.totem.block.type.TypeCondition;
|
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.DustParticleSetting;
|
||||||
import net.momirealms.customfishing.mechanic.totem.particle.ParticleSetting;
|
import net.momirealms.customfishing.mechanic.totem.particle.ParticleSetting;
|
||||||
import net.momirealms.customfishing.util.LocationUtils;
|
import net.momirealms.customfishing.util.LocationUtils;
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ public class SchedulerImpl implements Scheduler {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.syncScheduler = plugin.getVersionManager().isFolia() ?
|
this.syncScheduler = plugin.getVersionManager().isFolia() ?
|
||||||
new FoliaSchedulerImpl(plugin) : new BukkitSchedulerImpl(plugin);
|
new FoliaSchedulerImpl(plugin) : new BukkitSchedulerImpl(plugin);
|
||||||
this.schedule = new ScheduledThreadPoolExecutor(4);
|
this.schedule = new ScheduledThreadPoolExecutor(1);
|
||||||
this.schedule.setMaximumPoolSize(4);
|
this.schedule.setMaximumPoolSize(1);
|
||||||
this.schedule.setKeepAliveTime(10, TimeUnit.SECONDS);
|
this.schedule.setKeepAliveTime(30, TimeUnit.SECONDS);
|
||||||
this.schedule.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
this.schedule.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import redis.clients.jedis.*;
|
import redis.clients.jedis.*;
|
||||||
import redis.clients.jedis.exceptions.JedisException;
|
import redis.clients.jedis.exceptions.JedisException;
|
||||||
import redis.clients.jedis.resps.Tuple;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ public class ConfigUtils {
|
|||||||
* @param value The input string
|
* @param value The input string
|
||||||
* @return A Pair of integers
|
* @return A Pair of integers
|
||||||
*/
|
*/
|
||||||
public static Pair<Integer, Integer> splitStringIntegerArgs(String value) {
|
public static Pair<Integer, Integer> splitStringIntegerArgs(String value, String regex) {
|
||||||
String[] split = value.split("~");
|
String[] split = value.split(regex);
|
||||||
return Pair.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
return Pair.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ other-settings:
|
|||||||
thread-pool-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
|
# 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
|
# 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
|
# 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
|
# If a thread is idle for more than this attribute value, it will exit due to timeout
|
||||||
keepAliveTime: 30
|
keepAliveTime: 30
|
||||||
|
|
||||||
@@ -160,14 +160,13 @@ other-settings:
|
|||||||
# CustomFishing supports using items from other plugins
|
# CustomFishing supports using items from other plugins
|
||||||
# If items share the same id, they would inherit the effects
|
# If items share the same id, they would inherit the effects
|
||||||
item-detection-order:
|
item-detection-order:
|
||||||
# - Oraxen
|
|
||||||
# - ItemsAdder
|
|
||||||
- CustomFishing
|
- CustomFishing
|
||||||
- vanilla
|
- vanilla
|
||||||
|
|
||||||
block-detection-order:
|
block-detection-order:
|
||||||
- vanilla
|
- vanilla
|
||||||
|
|
||||||
|
# Custom durability format
|
||||||
custom-durability-format:
|
custom-durability-format:
|
||||||
- ''
|
- ''
|
||||||
- '<gray>Durability</gray><white>: {dur} <gray>/</gray> {max}</white>'
|
- '<gray>Durability</gray><white>: {dur} <gray>/</gray> {max}</white>'
|
||||||
|
|||||||
Reference in New Issue
Block a user