mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-30 20:39:18 +00:00
checkpoint - 12
This commit is contained in:
@@ -2,11 +2,13 @@ package net.momirealms.customfishing.bukkit;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.config.ConfigManager;
|
||||
import net.momirealms.customfishing.api.mechanic.item.ItemType;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.cooldown.CoolDownManager;
|
||||
import net.momirealms.customfishing.api.mechanic.misc.placeholder.BukkitPlaceholderManager;
|
||||
import net.momirealms.customfishing.bukkit.action.BukkitActionManager;
|
||||
import net.momirealms.customfishing.bukkit.bag.BukkitBagManager;
|
||||
import net.momirealms.customfishing.bukkit.block.BukkitBlockManager;
|
||||
import net.momirealms.customfishing.bukkit.command.BukkitCommandManager;
|
||||
import net.momirealms.customfishing.bukkit.competition.BukkitCompetitionManager;
|
||||
import net.momirealms.customfishing.bukkit.config.BukkitConfigManager;
|
||||
import net.momirealms.customfishing.bukkit.effect.BukkitEffectManager;
|
||||
@@ -19,6 +21,7 @@ import net.momirealms.customfishing.bukkit.item.BukkitItemManager;
|
||||
import net.momirealms.customfishing.bukkit.loot.BukkitLootManager;
|
||||
import net.momirealms.customfishing.bukkit.market.BukkitMarketManager;
|
||||
import net.momirealms.customfishing.bukkit.requirement.BukkitRequirementManager;
|
||||
import net.momirealms.customfishing.bukkit.scheduler.BukkitSchedulerAdapter;
|
||||
import net.momirealms.customfishing.bukkit.sender.BukkitSenderFactory;
|
||||
import net.momirealms.customfishing.bukkit.statistic.BukkitStatisticsManager;
|
||||
import net.momirealms.customfishing.bukkit.storage.BukkitStorageManager;
|
||||
@@ -43,13 +46,41 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
|
||||
private final ClassPathAppender classPathAppender;
|
||||
private final PluginLogger logger;
|
||||
private final ChatCatcherManager chatCatcherManager;
|
||||
private ChatCatcherManager chatCatcherManager;
|
||||
private BukkitCommandManager commandManager;
|
||||
|
||||
public BukkitCustomFishingPluginImpl(Plugin boostrap) {
|
||||
super(boostrap);
|
||||
VersionHelper.init(getServerVersion());
|
||||
this.scheduler = new BukkitSchedulerAdapter(this);
|
||||
this.classPathAppender = new ReflectionClassPathAppender(this);
|
||||
this.logger = new JavaPluginLogger(getBoostrap().getLogger());
|
||||
this.dependencyManager = new DependencyManagerImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
this.dependencyManager.loadDependencies(
|
||||
List.of(
|
||||
Dependency.BOOSTED_YAML,
|
||||
Dependency.BSTATS_BASE, Dependency.BSTATS_BUKKIT,
|
||||
Dependency.CAFFEINE,
|
||||
Dependency.GEANTY_REF,
|
||||
Dependency.CLOUD_CORE, Dependency.CLOUD_SERVICES, Dependency.CLOUD_BUKKIT, Dependency.CLOUD_PAPER, Dependency.CLOUD_BRIGADIER, Dependency.CLOUD_MINECRAFT_EXTRAS,
|
||||
Dependency.GSON,
|
||||
Dependency.COMMONS_POOL_2,
|
||||
Dependency.JEDIS,
|
||||
Dependency.EXP4J,
|
||||
Dependency.MYSQL_DRIVER, Dependency.MARIADB_DRIVER,
|
||||
Dependency.SQLITE_DRIVER,
|
||||
Dependency.H2_DRIVER,
|
||||
Dependency.MONGODB_DRIVER_CORE, Dependency.MONGODB_DRIVER_SYNC, Dependency.MONGODB_DRIVER_BSON,
|
||||
Dependency.HIKARI_CP)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
this.eventManager = new BukkitEventManager(this);
|
||||
this.configManager = new BukkitConfigManager(this);
|
||||
this.requirementManager = new BukkitRequirementManager(this);
|
||||
@@ -69,41 +100,11 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
this.effectManager = new BukkitEffectManager(this);
|
||||
this.hookManager = new BukkitHookManager(this);
|
||||
this.bagManager = new BukkitBagManager(this);
|
||||
this.dependencyManager = new DependencyManagerImpl(this);
|
||||
this.translationManager = new TranslationManager(this);
|
||||
this.chatCatcherManager = new ChatCatcherManager(this);
|
||||
}
|
||||
this.commandManager = new BukkitCommandManager(this);
|
||||
this.commandManager.registerDefaultFeatures();
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
this.dependencyManager.loadDependencies(
|
||||
List.of(Dependency.BOOSTED_YAML,
|
||||
Dependency.BSTATS_BASE,
|
||||
Dependency.BSTATS_BUKKIT,
|
||||
Dependency.CAFFEINE,
|
||||
Dependency.CLOUD_CORE,
|
||||
Dependency.CLOUD_SERVICES,
|
||||
Dependency.CLOUD_BUKKIT,
|
||||
Dependency.CLOUD_PAPER,
|
||||
Dependency.CLOUD_BRIGADIER,
|
||||
Dependency.CLOUD_MINECRAFT_EXTRAS,
|
||||
Dependency.GSON,
|
||||
Dependency.COMMONS_POOL_2,
|
||||
Dependency.JEDIS,
|
||||
Dependency.EXP4J,
|
||||
Dependency.MYSQL_DRIVER,
|
||||
Dependency.MARIADB_DRIVER,
|
||||
Dependency.SQLITE_DRIVER,
|
||||
Dependency.H2_DRIVER,
|
||||
Dependency.MONGODB_DRIVER_CORE,
|
||||
Dependency.MONGODB_DRIVER_SYNC,
|
||||
Dependency.MONGODB_DRIVER_BSON,
|
||||
Dependency.HIKARI_CP)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
this.reload();
|
||||
if (ConfigManager.metrics()) new Metrics((JavaPlugin) getBoostrap(), 16648);
|
||||
if (ConfigManager.checkUpdate()) {
|
||||
@@ -112,12 +113,13 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
else this.getPluginLogger().warn("Update is available: https://polymart.org/resource/2723");
|
||||
});
|
||||
}
|
||||
|
||||
this.integrationManager.load();
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
ItemType.reset();
|
||||
this.eventManager.reload();
|
||||
this.configManager.reload();
|
||||
this.requirementManager.reload();
|
||||
@@ -148,7 +150,6 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
this.itemManager.disable();
|
||||
this.competitionManager.disable();
|
||||
this.marketManager.disable();
|
||||
this.storageManager.disable();
|
||||
this.lootManager.disable();
|
||||
this.coolDownManager.disable();
|
||||
this.entityManager.disable();
|
||||
@@ -158,7 +159,8 @@ public class BukkitCustomFishingPluginImpl extends BukkitCustomFishingPlugin {
|
||||
this.hookManager.disable();
|
||||
this.bagManager.disable();
|
||||
this.integrationManager.disable();
|
||||
this.initialized = false;
|
||||
this.storageManager.disable();
|
||||
this.commandManager.unregisterFeatures();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,31 +2,47 @@ package net.momirealms.customfishing.bukkit.command;
|
||||
|
||||
import net.kyori.adventure.util.Index;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.command.feature.GetItemCommand;
|
||||
import net.momirealms.customfishing.bukkit.command.feature.GiveItemCommand;
|
||||
import net.momirealms.customfishing.bukkit.command.feature.ReloadCommand;
|
||||
import net.momirealms.customfishing.bukkit.command.feature.SellFishCommand;
|
||||
import net.momirealms.customfishing.common.command.AbstractCommandManager;
|
||||
import net.momirealms.customfishing.common.command.CommandFeature;
|
||||
import net.momirealms.customfishing.common.sender.Sender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.incendo.cloud.SenderMapper;
|
||||
import org.incendo.cloud.bukkit.CloudBukkitCapabilities;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.paper.PaperCommandManager;
|
||||
import org.incendo.cloud.paper.LegacyPaperCommandManager;
|
||||
import org.incendo.cloud.setting.ManagerSetting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitCommandManager extends AbstractCommandManager<CommandSender> {
|
||||
|
||||
private final List<CommandFeature<CommandSender>> FEATURES = List.of(
|
||||
new ReloadCommand(this)
|
||||
new ReloadCommand(this),
|
||||
new SellFishCommand(this),
|
||||
new GetItemCommand(this),
|
||||
new GiveItemCommand(this)
|
||||
);
|
||||
|
||||
private final Index<String, CommandFeature<CommandSender>> INDEX = Index.create(CommandFeature::getFeatureID, FEATURES);
|
||||
|
||||
public BukkitCommandManager(BukkitCustomFishingPlugin plugin) {
|
||||
super(plugin, new PaperCommandManager<>(
|
||||
super(plugin, new LegacyPaperCommandManager<>(
|
||||
plugin.getBoostrap(),
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
SenderMapper.identity()
|
||||
));
|
||||
final LegacyPaperCommandManager<CommandSender> manager = (LegacyPaperCommandManager<CommandSender>) getCommandManager();
|
||||
manager.settings().set(ManagerSetting.ALLOW_UNSAFE_REGISTRATION, true);
|
||||
if (manager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
|
||||
manager.registerBrigadier();
|
||||
manager.brigadierManager().setNativeNumberSuggestions(true);
|
||||
} else if (manager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
|
||||
manager.registerAsynchronousCompletions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package net.momirealms.customfishing.bukkit.command.feature;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.bukkit.command.BukkitCommandFeature;
|
||||
import net.momirealms.customfishing.bukkit.util.PlayerUtils;
|
||||
import net.momirealms.customfishing.common.command.CustomFishingCommandManager;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.context.CommandInput;
|
||||
import org.incendo.cloud.parser.standard.IntegerParser;
|
||||
import org.incendo.cloud.parser.standard.StringParser;
|
||||
import org.incendo.cloud.suggestion.Suggestion;
|
||||
import org.incendo.cloud.suggestion.SuggestionProvider;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class GetItemCommand extends BukkitCommandFeature<CommandSender> {
|
||||
|
||||
public GetItemCommand(CustomFishingCommandManager<CommandSender> commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command.Builder<? extends CommandSender> assembleCommand(CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
|
||||
return builder
|
||||
.senderType(Player.class)
|
||||
.required("id", StringParser.stringComponent().suggestionProvider(new SuggestionProvider<>() {
|
||||
@Override
|
||||
public @NonNull CompletableFuture<? extends @NonNull Iterable<? extends @NonNull Suggestion>> suggestionsFuture(@NonNull CommandContext<Object> context, @NonNull CommandInput input) {
|
||||
return CompletableFuture.completedFuture(BukkitCustomFishingPlugin.getInstance().getItemManager().getItemIDs().stream().map(Suggestion::suggestion).toList());
|
||||
}
|
||||
}))
|
||||
.optional("amount", IntegerParser.integerParser(1, 6400))
|
||||
.flag(manager.flagBuilder("silent").withAliases("s").build())
|
||||
.handler(context -> {
|
||||
final int amount = context.getOrDefault("amount", 1);
|
||||
final String id = context.get("id");
|
||||
final Player player = context.sender();
|
||||
try {
|
||||
ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player).arg(ContextKeys.ID, id), id);
|
||||
if (itemStack == null) {
|
||||
throw new RuntimeException("Unrecognized item id: " + id);
|
||||
}
|
||||
int amountToGive = amount;
|
||||
int maxStack = itemStack.getType().getMaxStackSize();
|
||||
while (amountToGive > 0) {
|
||||
int perStackSize = Math.min(maxStack, amountToGive);
|
||||
amountToGive -= perStackSize;
|
||||
ItemStack more = itemStack.clone();
|
||||
more.setAmount(perStackSize);
|
||||
PlayerUtils.dropItem(player, more, false, true, false);
|
||||
}
|
||||
handleFeedback(context, MessageConstants.COMMAND_ITEM_GET_SUCCESS, Component.text(amount), Component.text(id));
|
||||
} catch (NullPointerException e) {
|
||||
handleFeedback(context, MessageConstants.COMMAND_ITEM_FAILURE_NOT_EXIST, Component.text(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFeatureID() {
|
||||
return "getitem";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package net.momirealms.customfishing.bukkit.command.feature;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.bukkit.command.BukkitCommandFeature;
|
||||
import net.momirealms.customfishing.bukkit.util.PlayerUtils;
|
||||
import net.momirealms.customfishing.common.command.CustomFishingCommandManager;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.bukkit.data.MultiplePlayerSelector;
|
||||
import org.incendo.cloud.bukkit.parser.PlayerParser;
|
||||
import org.incendo.cloud.bukkit.parser.selector.MultiplePlayerSelectorParser;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.context.CommandInput;
|
||||
import org.incendo.cloud.parser.standard.IntegerParser;
|
||||
import org.incendo.cloud.parser.standard.StringParser;
|
||||
import org.incendo.cloud.suggestion.Suggestion;
|
||||
import org.incendo.cloud.suggestion.SuggestionProvider;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class GiveItemCommand extends BukkitCommandFeature<CommandSender> {
|
||||
|
||||
public GiveItemCommand(CustomFishingCommandManager<CommandSender> commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command.Builder<? extends CommandSender> assembleCommand(CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
|
||||
return builder
|
||||
.required("player", PlayerParser.playerParser())
|
||||
.required("id", StringParser.stringComponent().suggestionProvider(new SuggestionProvider<>() {
|
||||
@Override
|
||||
public @NonNull CompletableFuture<? extends @NonNull Iterable<? extends @NonNull Suggestion>> suggestionsFuture(@NonNull CommandContext<Object> context, @NonNull CommandInput input) {
|
||||
return CompletableFuture.completedFuture(BukkitCustomFishingPlugin.getInstance().getItemManager().getItemIDs().stream().map(Suggestion::suggestion).toList());
|
||||
}
|
||||
}))
|
||||
.optional("amount", IntegerParser.integerParser(1, 6400))
|
||||
.flag(manager.flagBuilder("silent").withAliases("s").build())
|
||||
.handler(context -> {
|
||||
final Player player = context.get("player");
|
||||
final int amount = context.getOrDefault("amount", 1);
|
||||
final String id = context.get("id");
|
||||
try {
|
||||
ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player).arg(ContextKeys.ID, id), id);
|
||||
if (itemStack == null) {
|
||||
throw new RuntimeException("Unrecognized item id: " + id);
|
||||
}
|
||||
int amountToGive = amount;
|
||||
int maxStack = itemStack.getType().getMaxStackSize();
|
||||
while (amountToGive > 0) {
|
||||
int perStackSize = Math.min(maxStack, amountToGive);
|
||||
amountToGive -= perStackSize;
|
||||
ItemStack more = itemStack.clone();
|
||||
more.setAmount(perStackSize);
|
||||
PlayerUtils.dropItem(player, more, false, true, false);
|
||||
}
|
||||
handleFeedback(context, MessageConstants.COMMAND_ITEM_GIVE_SUCCESS, Component.text(player.getName()), Component.text(amount), Component.text(id));
|
||||
} catch (NullPointerException e) {
|
||||
handleFeedback(context, MessageConstants.COMMAND_ITEM_FAILURE_NOT_EXIST, Component.text(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFeatureID() {
|
||||
return "giveitem";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.customfishing.bukkit.command.feature;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.command.BukkitCommandFeature;
|
||||
import net.momirealms.customfishing.common.command.CustomFishingCommandManager;
|
||||
@@ -17,10 +18,11 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
|
||||
@Override
|
||||
public Command.Builder<? extends CommandSender> assembleCommand(CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
|
||||
return builder
|
||||
.flag(manager.flagBuilder("silent"))
|
||||
.flag(manager.flagBuilder("silent").withAliases("s"))
|
||||
.handler(context -> {
|
||||
long time1 = System.currentTimeMillis();
|
||||
BukkitCustomFishingPlugin.getInstance().reload();
|
||||
handleFeedback(context.sender(), MessageConstants.COMMAND_RELOAD_SUCCESS);
|
||||
handleFeedback(context, MessageConstants.COMMAND_RELOAD_SUCCESS, Component.text(System.currentTimeMillis() - time1));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.momirealms.customfishing.bukkit.command.feature;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.command.BukkitCommandFeature;
|
||||
import net.momirealms.customfishing.common.command.CustomFishingCommandManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
|
||||
public class SellFishCommand extends BukkitCommandFeature<CommandSender> {
|
||||
|
||||
public SellFishCommand(CustomFishingCommandManager<CommandSender> commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command.Builder<? extends CommandSender> assembleCommand(CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
|
||||
return builder
|
||||
.senderType(Player.class)
|
||||
.handler(context -> BukkitCustomFishingPlugin.getInstance().getMarketManager().openMarketGUI(context.sender()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFeatureID() {
|
||||
return "sellfish";
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
if (subFile.isDirectory()) {
|
||||
fileDeque.push(subFile);
|
||||
} else if (subFile.isFile() && subFile.getName().endsWith(".yml")) {
|
||||
YamlDocument document = plugin.getConfigManager().loadData(file);
|
||||
YamlDocument document = plugin.getConfigManager().loadData(subFile);
|
||||
for (Map.Entry<String, Object> entry : document.getStringRouteMappedValues(false).entrySet()) {
|
||||
if (entry.getValue() instanceof Section section) {
|
||||
type.parse(entry.getKey(), section, formatFunctions);
|
||||
@@ -79,7 +79,7 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
return (item, context) -> item.customModelData((int) mathValue.evaluate(context));
|
||||
}, 5000, "custom-model-data");
|
||||
this.registerItemParser(arg -> {
|
||||
TextValue<Player> textValue = TextValue.auto((String) arg);
|
||||
TextValue<Player> textValue = TextValue.auto("<!i><white>" + arg);
|
||||
return (item, context) -> {
|
||||
item.displayName(AdventureHelper.miniMessageToJson(textValue.render(context)));
|
||||
};
|
||||
@@ -88,7 +88,7 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
List<String> list = ListUtils.toList(arg);
|
||||
List<TextValue<Player>> lore = new ArrayList<>();
|
||||
for (String text : list) {
|
||||
lore.add(TextValue.auto(text));
|
||||
lore.add(TextValue.auto("<!i><white>" + text));
|
||||
}
|
||||
return (item, context) -> {
|
||||
item.lore(lore.stream()
|
||||
@@ -101,7 +101,6 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
return (item, context) -> {
|
||||
if (!enable) return;
|
||||
item.setTag(context.arg(ContextKeys.ID), "CustomFishing", "id");
|
||||
item.setTag(context.arg(ContextKeys.TYPE), "CustomFishing", "type");
|
||||
};
|
||||
}, 2_000, "tag");
|
||||
this.registerItemParser(arg -> {
|
||||
@@ -119,8 +118,8 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
}, 1_000, "size");
|
||||
this.registerItemParser(arg -> {
|
||||
Section section = (Section) arg;
|
||||
MathValue<Player> base = MathValue.auto(section.get("base"));
|
||||
MathValue<Player> bonus = MathValue.auto(section.get("bonus"));
|
||||
MathValue<Player> base = MathValue.auto(section.get("base", "0"));
|
||||
MathValue<Player> bonus = MathValue.auto(section.get("bonus", "0"));
|
||||
return (item, context) -> {
|
||||
double basePrice = base.evaluate(context);
|
||||
double bonusPrice = bonus.evaluate(context);
|
||||
@@ -325,12 +324,12 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
return builder -> builder.entityID(entity);
|
||||
}, "entity");
|
||||
this.registerEntityParser(object -> {
|
||||
String entity = (String) object;
|
||||
return builder -> builder.entityID(entity);
|
||||
MathValue<Player> mathValue = MathValue.auto(object);
|
||||
return builder -> builder.horizontalVector(mathValue);
|
||||
}, "velocity", "horizontal");
|
||||
this.registerEntityParser(object -> {
|
||||
String entity = (String) object;
|
||||
return builder -> builder.entityID(entity);
|
||||
MathValue<Player> mathValue = MathValue.auto(object);
|
||||
return builder -> builder.verticalVector(mathValue);
|
||||
}, "velocity", "vertical");
|
||||
this.registerEntityParser(object -> {
|
||||
Section section = (Section) object;
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.momirealms.customfishing.bukkit.gui.icon.property.item;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -19,7 +19,6 @@ package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
|
||||
@@ -19,7 +19,6 @@ package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import com.saicone.rtag.RtagItem;
|
||||
import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
@@ -27,16 +26,13 @@ import net.momirealms.customfishing.bukkit.gui.icon.BackToFolderItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.NextPageItem;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.PreviousPageItem;
|
||||
import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.helper.VersionHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.xenondevs.invui.gui.Gui;
|
||||
import xyz.xenondevs.invui.gui.PagedGui;
|
||||
@@ -48,7 +44,6 @@ import xyz.xenondevs.invui.item.impl.AbstractItem;
|
||||
import xyz.xenondevs.invui.item.impl.SimpleItem;
|
||||
import xyz.xenondevs.invui.window.AnvilWindow;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -19,7 +19,6 @@ package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.momirealms.customfishing.bukkit.gui.page.item;
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.item.*;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.property.loot.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.xenondevs.invui.item.Item;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package net.momirealms.customfishing.bukkit.gui.page.property;
|
||||
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.adventure.ShadedAdventureComponentWrapper;
|
||||
import net.momirealms.customfishing.bukkit.gui.SectionPage;
|
||||
import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
@@ -26,7 +25,6 @@ import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.momirealms.customfishing.bukkit.gui.icon.BackGroundItem;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.momirealms.customfishing.common.helper.AdventureHelper;
|
||||
import net.momirealms.customfishing.common.locale.MessageConstants;
|
||||
import net.momirealms.customfishing.common.locale.TranslationManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import net.momirealms.customfishing.api.mechanic.item.CustomFishingItem;
|
||||
import net.momirealms.customfishing.api.mechanic.item.ItemManager;
|
||||
import net.momirealms.customfishing.api.mechanic.item.ItemType;
|
||||
import net.momirealms.customfishing.bukkit.util.ItemUtils;
|
||||
import net.momirealms.customfishing.bukkit.util.LocationUtils;
|
||||
import net.momirealms.customfishing.common.item.Item;
|
||||
@@ -33,10 +34,7 @@ import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@@ -97,13 +95,13 @@ public class BukkitItemManager implements ItemManager, Listener {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack build(@NotNull Context<Player> context, CustomFishingItem item) {
|
||||
public ItemStack build(@NotNull Context<Player> context, @NotNull CustomFishingItem item) {
|
||||
ItemStack itemStack = getOriginalStack(context.getHolder(), item.material());
|
||||
Item<ItemStack> wrappedItemStack = factory.wrap(itemStack);
|
||||
for (BiConsumer<Item<ItemStack>, Context<Player>> consumer : item.tagConsumers()) {
|
||||
consumer.accept(wrappedItemStack, context);
|
||||
}
|
||||
return wrappedItemStack.getItem();
|
||||
return wrappedItemStack.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,6 +128,18 @@ public class BukkitItemManager implements ItemManager, Listener {
|
||||
return (String) factory.wrap(itemStack).getTag("CustomFishing", "id").orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemType getItemType(@NotNull ItemStack itemStack) {
|
||||
return ItemType.getTypeByID(getCustomFishingItemID(itemStack));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemType getItemType(@NotNull String id) {
|
||||
return ItemType.getTypeByID(id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
@@ -316,4 +326,9 @@ public class BukkitItemManager implements ItemManager, Listener {
|
||||
public ItemProvider[] getItemProviders() {
|
||||
return itemProviders.values().toArray(new ItemProvider[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getItemIDs() {
|
||||
return items.keySet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,6 @@ public class BukkitMarketManager implements MarketManager, Listener {
|
||||
*/
|
||||
@Override
|
||||
public void openMarketGUI(Player player) {
|
||||
if (!enable) return;
|
||||
Optional<UserData> optionalUserData = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
if (optionalUserData.isEmpty()) {
|
||||
plugin.getPluginLogger().warn("Player " + player.getName() + "'s market data is not loaded yet.");
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
package net.momirealms.customfishing.bukkit.scheduler;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.bukkit.scheduler.impl.BukkitExecutor;
|
||||
import net.momirealms.customfishing.bukkit.scheduler.impl.FoliaExecutor;
|
||||
import net.momirealms.customfishing.common.helper.VersionHelper;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.AbstractJavaScheduler;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.RegionExecutor;
|
||||
import org.bukkit.Location;
|
||||
@@ -33,9 +36,13 @@ import org.bukkit.Location;
|
||||
public class BukkitSchedulerAdapter extends AbstractJavaScheduler<Location> {
|
||||
protected RegionExecutor<Location> sync;
|
||||
|
||||
public BukkitSchedulerAdapter(BukkitCustomFishingPlugin plugin, RegionExecutor<Location> executor) {
|
||||
public BukkitSchedulerAdapter(BukkitCustomFishingPlugin plugin) {
|
||||
super(plugin);
|
||||
this.sync = executor;
|
||||
if (VersionHelper.isFolia()) {
|
||||
this.sync = new FoliaExecutor(plugin.getBoostrap());
|
||||
} else {
|
||||
this.sync = new BukkitExecutor(plugin.getBoostrap());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.bukkit.scheduler.impl;
|
||||
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.RegionExecutor;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BukkitExecutor implements RegionExecutor<Location> {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
public BukkitExecutor(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Runnable r, Location l) {
|
||||
Bukkit.getScheduler().runTask(plugin, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask runLater(Runnable r, long delayTicks, Location l) {
|
||||
return Bukkit.getScheduler().runTaskLater(plugin, r, delayTicks)::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask runRepeating(Runnable r, long delayTicks, long period, Location l) {
|
||||
return Bukkit.getScheduler().runTaskTimer(plugin, r, delayTicks, period)::cancel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.bukkit.scheduler.impl;
|
||||
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.RegionExecutor;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class FoliaExecutor implements RegionExecutor<Location> {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
public FoliaExecutor(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Runnable r, Location l) {
|
||||
Optional.ofNullable(l).ifPresentOrElse(loc -> Bukkit.getRegionScheduler().execute(plugin, loc, r), () -> Bukkit.getGlobalRegionScheduler().execute(plugin, r));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask runLater(Runnable r, long delayTicks, Location l) {
|
||||
if (l == null) {
|
||||
return Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask -> r.run(), delayTicks)::cancel;
|
||||
} else {
|
||||
return Bukkit.getRegionScheduler().runDelayed(plugin, l, scheduledTask -> r.run(), delayTicks)::cancel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask runRepeating(Runnable r, long delayTicks, long period, Location l) {
|
||||
if (l == null) {
|
||||
return Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, scheduledTask -> r.run(), delayTicks, period)::cancel;
|
||||
} else {
|
||||
return Bukkit.getRegionScheduler().runAtFixedRate(plugin, l, scheduledTask -> r.run(), delayTicks, period)::cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.storage.StorageType;
|
||||
import net.momirealms.customfishing.common.dependency.Dependency;
|
||||
import org.h2.jdbcx.JdbcConnectionPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -17,38 +17,8 @@
|
||||
|
||||
package net.momirealms.customfishing.bukkit.totem;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.totem.TotemConfig;
|
||||
import net.momirealms.customfishing.api.mechanic.totem.TotemManager;
|
||||
import net.momirealms.customfishing.api.mechanic.totem.TotemModel;
|
||||
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.util.SimpleLocation;
|
||||
import net.momirealms.customfishing.bukkit.totem.particle.DustParticleSetting;
|
||||
import net.momirealms.customfishing.bukkit.totem.particle.ParticleSetting;
|
||||
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask;
|
||||
import net.momirealms.customfishing.common.util.Pair;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BukkitTotemManager implements TotemManager, Listener {
|
||||
|
||||
|
||||
@@ -8,13 +8,27 @@ config-version: "${config_version}"
|
||||
#
|
||||
reload:
|
||||
enable: true
|
||||
permission: customfishing.reload
|
||||
permission: customfishing.command.reload
|
||||
usage:
|
||||
- /customfishing reload
|
||||
- /cfishing reload
|
||||
|
||||
sellfish:
|
||||
enable: true
|
||||
permission: customfishing.sellfish
|
||||
permission: customfishing.command.sellfish
|
||||
usage:
|
||||
- /sellfish
|
||||
- /sellfish
|
||||
|
||||
getitem:
|
||||
enable: true
|
||||
permission: customfishing.command.getitem
|
||||
usage:
|
||||
- /customfishing items get
|
||||
- /cfishing items get
|
||||
|
||||
giveitem:
|
||||
enable: true
|
||||
permission: customfishing.command.giveitem
|
||||
usage:
|
||||
- /customfishing items give
|
||||
- /cfishing items give
|
||||
@@ -1,7 +1,5 @@
|
||||
config-version: '${config_version}'
|
||||
|
||||
enable: true
|
||||
|
||||
# Container title
|
||||
title: '<gradient:#A52A2A:#800000:#A52A2A>Fish Market</gradient>'
|
||||
|
||||
|
||||
@@ -3,21 +3,21 @@ config-version: "31"
|
||||
|
||||
command.prefix: "<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient>"
|
||||
command.reload.success: "<white>Reloaded. Took <green><arg:0></green>ms.</white>"
|
||||
command.item.failure.not_exist: "<red>Item not exists</red>"
|
||||
command.item.give.success: "Successfully given player <arg:0> <arg:1>x <arg:2>."
|
||||
command.item.get.success: "Successfully got <arg:0>x <arg:1>."
|
||||
command.item.failure.not_exist: "<red>Item [<arg:0>] not exists.</red>"
|
||||
command.item.give.success: "<white>Successfully given <arg:0> <arg:1>x <arg:2>.</white>"
|
||||
command.item.get.success: "<white>Successfully got <arg:0>x <arg:1>.</white>"
|
||||
command.fish_finder.possible_loots: "Possible loots here: "
|
||||
command.fish_finder.no_loot: "No loot available"
|
||||
command.fish_finder.split_char: ", "
|
||||
command.competition.failure.not_exist: "Competition <arg:0> does not exist."
|
||||
command.competition.failure.no_competition: "There's no competition ongoing."
|
||||
command.competition.stop.success: "Stopped the current competition."
|
||||
command.competition.end.success: "Ended the current competition."
|
||||
command.bag.edit.failure.unsafe: "Cannot edit a player's fishing bag if they"re active on another linked server."
|
||||
command.bag.edit.failure.never_played: 'The player hasn\'t joined the server before. Can't modify a nonexistent player"s fishing bag."
|
||||
command.bag.open.success: "Successfully opened the fishing bag for <arg:0>"
|
||||
command.data.failure.not_load: '<red>Data hasn't loaded. Please re-enter the server. If issues persist, reach out to the server admin.</red>"
|
||||
command.market.open.success: "Successfully opened the market gui for <arg:0>"
|
||||
command.competition.failure.not_exist: "<red>Competition <arg:0> does not exist.</red>"
|
||||
command.competition.failure.no_competition: "<red>There's no competition ongoing.</red>"
|
||||
command.competition.stop.success: "<white>Stopped the current competition.</white>"
|
||||
command.competition.end.success: "<white>Ended the current competition.</white>"
|
||||
command.bag.edit.failure.unsafe: "<red>Cannot edit a player's fishing bag if they're active on another linked server.</red>"
|
||||
command.bag.edit.failure.never_played: "<red>The player hasn't joined the server before. Can't modify a nonexistent player's fishing bag.</red>"
|
||||
command.bag.open.success: "<white>Successfully opened the fishing bag for <arg:0></white>"
|
||||
command.data.failure.not_load: "<red>Data hasn't been loaded. Please re-enter the server. If issues persist, reach out to the server admin.</red>"
|
||||
command.market.open.success: "<white>Successfully opened the market gui for <arg:0></white>"
|
||||
competition.no_score: "No Score"
|
||||
competition.no_player: "No Player"
|
||||
competition.no_rank: "No Rank"
|
||||
@@ -41,14 +41,14 @@ gui.invalid_number: "<red>● Invalid number"
|
||||
gui.illegal_format: "<red>● Illegal format"
|
||||
gui.scroll_up: "<gray>● Scroll up"
|
||||
gui.scroll_down: "<gray>● Scroll down"
|
||||
gui.cannot_scroll_up: "<red>You"ve reached the top"
|
||||
gui.cannot_scroll_down: "<red>You can"t scroll further down"
|
||||
gui.cannot_scroll_up: "<red>You've reached the top"
|
||||
gui.cannot_scroll_down: "<red>You can't scroll further down"
|
||||
gui.next_page: "<gray>● Next Page"
|
||||
gui.goto_next_page: "<gray>Go to page <yellow><arg:0> <gray>/ <yellow><arg:1>"
|
||||
gui.cannot_goto_next_page: "<red>There are no more pages"
|
||||
gui.previous_page: "<gray>● Previous page"
|
||||
gui.goto_previous_page: "<gray>Go to page <yellow><arg:0> <gray>/ <yellow><arg:1>"
|
||||
gui.cannot_goto_previous_page: "<red>You can"t go further back"
|
||||
gui.cannot_goto_previous_page: "<red>You can't go further back"
|
||||
gui.back_to_parent_page: "<#FF8C00>Back to parent page"
|
||||
gui.back_to_parent_folder: "<#FF8C00>Back to parent folder"
|
||||
gui.current_value: "<gray>Current value: <white><arg:0>"
|
||||
|
||||
Reference in New Issue
Block a user