├── .gitignore ├── README.md ├── dependency-reduced-pom.xml ├── pom.xml └── src ├── main ├── java │ └── me │ │ └── matl114 │ │ └── logitech │ │ ├── ConfigLoader.java │ │ ├── Language.java │ │ ├── MyAddon.java │ │ ├── Unittest.java │ │ ├── core │ │ ├── AddGroups.java │ │ ├── AddItem.java │ │ ├── AddSlimefunItems.java │ │ ├── Blank.java │ │ ├── Blocks │ │ │ ├── AbstractBlock.java │ │ │ ├── AbstractSpawner.java │ │ │ ├── Laser.java │ │ │ ├── MultiBlock │ │ │ │ ├── FinalAltarCore.java │ │ │ │ ├── MultiBlockAdvancedProcessor.java │ │ │ │ ├── MultiBlockProcessor.java │ │ │ │ ├── MultiIOPort.java │ │ │ │ ├── PortalCore.java │ │ │ │ ├── SmithWorkShop │ │ │ │ │ ├── InterfacedSmithTableTrimmer.java │ │ │ │ │ ├── SWAmplifyComponent.java │ │ │ │ │ ├── SmithInterfaceCharger.java │ │ │ │ │ ├── SmithInterfaceCraftingLogic.java │ │ │ │ │ ├── SmithInterfaceProcessor.java │ │ │ │ │ ├── SmithingInterface.java │ │ │ │ │ └── SmithingWorkshop.java │ │ │ │ ├── SolarReactorCore.java │ │ │ │ └── Transmutator.java │ │ │ ├── MultiBlockCore │ │ │ │ ├── MultiBlockCore.java │ │ │ │ ├── MultiBlockPart.java │ │ │ │ ├── MultiCore.java │ │ │ │ └── MultiPart.java │ │ │ ├── SpreadBlock.java │ │ │ └── WitherProofBlock.java │ │ ├── Cargo │ │ │ ├── AbstractCargo.java │ │ │ ├── CargoMachine │ │ │ │ ├── AbstractFilter.java │ │ │ │ ├── AbstractSorter.java │ │ │ │ ├── AbstractSyncTickCargo.java │ │ │ │ ├── BiFilter.java │ │ │ │ ├── BiSorter.java │ │ │ │ ├── OctaFilter.java │ │ │ │ ├── OctaSorter.java │ │ │ │ ├── QuantumTrashCan.java │ │ │ │ ├── QuarFilter.java │ │ │ │ ├── QuarSorter.java │ │ │ │ ├── StorageCleaner.java │ │ │ │ ├── StorageOperator.java │ │ │ │ └── TrashCan.java │ │ │ ├── Config │ │ │ │ ├── CargoConfigCard.java │ │ │ │ ├── ChipCard.java │ │ │ │ ├── ChipCardCode.java │ │ │ │ ├── ChipControllable.java │ │ │ │ └── ConfigCard.java │ │ │ ├── Links │ │ │ │ ├── HyperLink.java │ │ │ │ └── StorageLink.java │ │ │ ├── Singularity │ │ │ │ ├── SingularityProxy.java │ │ │ │ └── SingularityStorage.java │ │ │ ├── SpaceStorage │ │ │ │ ├── SpaceStorageCard.java │ │ │ │ ├── SpaceTower.java │ │ │ │ ├── SpaceTowerFrame.java │ │ │ │ └── StorageSpace.java │ │ │ ├── StorageMachines │ │ │ │ ├── AbstractIOPort.java │ │ │ │ ├── IOPort.java │ │ │ │ ├── InputPort.java │ │ │ │ ├── OutputPort.java │ │ │ │ └── Storage.java │ │ │ ├── Storages.java │ │ │ ├── TestStorageUnit.java │ │ │ ├── Transportation │ │ │ │ ├── AdjacentCargo.java │ │ │ │ ├── AdjacentCargoPlus.java │ │ │ │ ├── CargoPipe.java │ │ │ │ ├── ChipAdjacentCargo.java │ │ │ │ ├── LineCargo.java │ │ │ │ ├── LineCargoPlus.java │ │ │ │ ├── RedstoneAdjacentCargo.java │ │ │ │ ├── RemoteCargo.java │ │ │ │ └── RemoteCargoPlus.java │ │ │ └── WorkBench │ │ │ │ ├── CargoConfigurator.java │ │ │ │ ├── ChipBiConsumer.java │ │ │ │ ├── ChipConsumer.java │ │ │ │ └── ChipCopier.java │ │ ├── CustomSlimefunItem.java │ │ ├── Depends │ │ │ ├── DependencyInfinity.java │ │ │ ├── DependencyNetwork.java │ │ │ ├── FinalTechAdapter.java │ │ │ ├── NetWorkQuantumMethod.java │ │ │ ├── NetworksQuantumProxyAdapter.java │ │ │ ├── NetworksQuantumStorageAdapter.java │ │ │ └── SupportedPluginManager.java │ │ ├── DistinctiveCustomSlimefunItem.java │ │ ├── Interface │ │ │ ├── ChunkLimit.java │ │ │ ├── DirectionalBlock.java │ │ │ ├── EnergyProvider.java │ │ │ ├── LogiTechChargable.java │ │ │ ├── MenuBlock.java │ │ │ ├── MenuTogglableBlock.java │ │ │ ├── MultiCraftType.java │ │ │ ├── RecipeDisplay.java │ │ │ └── RecipeLock.java │ │ ├── Items │ │ │ ├── Abstracts │ │ │ │ ├── AbstractGeoResource.java │ │ │ │ ├── ChargableProps.java │ │ │ │ ├── CustomArmorPiece.java │ │ │ │ ├── CustomItemNotPlaceable.java │ │ │ │ ├── CustomItemWithHandler.java │ │ │ │ ├── CustomProps.java │ │ │ │ ├── DataRecordedItem.java │ │ │ │ ├── FunctionalItem.java │ │ │ │ ├── MaterialItem.java │ │ │ │ └── MyVanillaItem.java │ │ │ ├── Equipments │ │ │ │ ├── AntiGravityBar.java │ │ │ │ ├── DisplayUseTrimmerLogic.java │ │ │ │ ├── DisplayUseTrimmerLogicLate.java │ │ │ │ ├── EquipmentFUItem.java │ │ │ │ ├── LaserGun.java │ │ │ │ └── TrackingArrowLauncher.java │ │ │ └── SpecialItems │ │ │ │ ├── BNoiseHead.java │ │ │ │ ├── ConfigCopier.java │ │ │ │ ├── EntityFeat.java │ │ │ │ ├── HypLink.java │ │ │ │ ├── MultiBlockBuilder.java │ │ │ │ ├── PlayerIdCard.java │ │ │ │ ├── QuantumLink.java │ │ │ │ ├── ReplaceCard.java │ │ │ │ └── Singularity.java │ │ ├── Machines │ │ │ ├── Abstracts │ │ │ │ ├── AbstractAdvancedProcessor.java │ │ │ │ ├── AbstractEnergyMachine.java │ │ │ │ ├── AbstractEnergyProcessor.java │ │ │ │ ├── AbstractEnergyProvider.java │ │ │ │ ├── AbstractMachine.java │ │ │ │ ├── AbstractManual.java │ │ │ │ ├── AbstractMultiThreadProcessor.java │ │ │ │ ├── AbstractProcessor.java │ │ │ │ ├── AbstractSequenceProcessor.java │ │ │ │ ├── AbstractTransformer.java │ │ │ │ └── AbstractWorkBench.java │ │ │ ├── AutoMachines │ │ │ │ ├── AEMachine.java │ │ │ │ ├── AdvanceCrafter.java │ │ │ │ ├── AdvanceRecipeCrafter.java │ │ │ │ ├── AdvancedSpecialCrafter.java │ │ │ │ ├── EMachine.java │ │ │ │ ├── FinalMGenerator.java │ │ │ │ ├── FinalSequenceConstructor.java │ │ │ │ ├── FinalStackMGenerator.java │ │ │ │ ├── FinalStackMachine.java │ │ │ │ ├── InverseMachine.java │ │ │ │ ├── MMGenerator.java │ │ │ │ ├── MTMachine.java │ │ │ │ ├── REMachine.java │ │ │ │ ├── SMGenerator.java │ │ │ │ ├── SequenceConstructor.java │ │ │ │ ├── SpecialCrafter.java │ │ │ │ ├── SpecialTypeCrafter.java │ │ │ │ ├── StackMGenerator.java │ │ │ │ └── StackMachine.java │ │ │ ├── Electrics │ │ │ │ ├── AbstractEnergyCharger.java │ │ │ │ ├── AbstractEnergyCollector.java │ │ │ │ ├── AbstractPipe.java │ │ │ │ ├── AdjacentEnergyCharger.java │ │ │ │ ├── AdjacentEnergyCollector.java │ │ │ │ ├── BiReactor.java │ │ │ │ ├── Capacitor.java │ │ │ │ ├── ChipReactor.java │ │ │ │ ├── ChunkEnergyCharger.java │ │ │ │ ├── EGenerator.java │ │ │ │ ├── EnergyAmplifier.java │ │ │ │ ├── EnergyIOStorage.java │ │ │ │ ├── EnergyPipe.java │ │ │ │ ├── EnergyStorage.java │ │ │ │ ├── EnergyTrash.java │ │ │ │ ├── LineEnergyCharger.java │ │ │ │ ├── LineEnergyCollector.java │ │ │ │ ├── SimulateTestGenerator.java │ │ │ │ └── TestGenerator.java │ │ │ ├── EmptyMachineSample.java │ │ │ ├── ManualMachines │ │ │ │ ├── AdvancedManual.java │ │ │ │ ├── FinalManual.java │ │ │ │ ├── ManualCrafter.java │ │ │ │ ├── ManualMachine.java │ │ │ │ ├── MultiBlockManual.java │ │ │ │ ├── PortableManual.java │ │ │ │ └── RandOutManulCrafter.java │ │ │ ├── SpecialMachines │ │ │ │ ├── AbstractTimerRange.java │ │ │ │ ├── AttributeOperator.java │ │ │ │ ├── BNoiseMaker.java │ │ │ │ ├── BoolGenerator.java │ │ │ │ ├── FinalConvertor.java │ │ │ │ ├── HeadAnalyzer.java │ │ │ │ ├── ItemOperator.java │ │ │ │ ├── LogicReactor.java │ │ │ │ ├── RandomEditor.java │ │ │ │ ├── RealKiller.java │ │ │ │ ├── RegisteryLogger.java │ │ │ │ ├── TimerBlockEntity.java │ │ │ │ ├── TimerRandomtick.java │ │ │ │ ├── TimerSequentialSlimefun.java │ │ │ │ ├── TimerSlimefun.java │ │ │ │ ├── TntGenerator.java │ │ │ │ ├── VirtualExplorer.java │ │ │ │ └── VirtualKiller.java │ │ │ └── WorkBenchs │ │ │ │ ├── BugCrafter.java │ │ │ │ ├── EWorkBench.java │ │ │ │ └── TestWorkBench.java │ │ └── Registries │ │ │ ├── AddDepends.java │ │ │ ├── AddHandlers.java │ │ │ ├── CustomEffects.java │ │ │ ├── EFUImplements.java │ │ │ ├── FinalFeature.java │ │ │ ├── MultiBlockTypes.java │ │ │ └── RecipeSupporter.java │ │ ├── listeners │ │ ├── BlockBreakListener.java │ │ ├── ChunkTestListener.java │ │ ├── CustomListener.java │ │ ├── Events │ │ │ ├── AttackPermissionTestEvent.java │ │ │ └── InteractPermissionTestEvent.java │ │ ├── ListenerManager.java │ │ ├── Listeners │ │ │ ├── BlockMenuClickProtectListener.java │ │ │ ├── BlockOpenListener.java │ │ │ ├── CombatListener.java │ │ │ ├── CraftingListener.java │ │ │ ├── HyperLinkListener.java │ │ │ ├── LaserGunOnHeadListener.java │ │ │ ├── MilkListener.java │ │ │ ├── MultiBlockVanillaPartListener.java │ │ │ ├── PlayerInSolar.java │ │ │ ├── PlayerQuiteListener.java │ │ │ ├── PortalTeleport.java │ │ │ ├── PotionClearOnDeath.java │ │ │ ├── SlimefunBlockPlaceLimitListener.java │ │ │ ├── SmeltingListener.java │ │ │ ├── SmithInterfaceListener.java │ │ │ ├── SpawnerListener.java │ │ │ ├── StorageWorldListener.java │ │ │ ├── SuperSpongeDryListener.java │ │ │ └── TickBlockListener.java │ │ ├── ProtectionManager.java │ │ └── ProtectionModule │ │ │ └── StorageWorldProtection.java │ │ ├── manager │ │ ├── EffectTickManager.java │ │ ├── EquipmentFUManager.java │ │ ├── PostSetupTasks.java │ │ ├── RadiationRegionManager.java │ │ ├── ScheduleSave.java │ │ └── Schedules.java │ │ └── utils │ │ ├── AddUtils.java │ │ ├── Algorithms │ │ ├── AtomicCounter.java │ │ ├── DynamicArray.java │ │ ├── DynamicMapper.java │ │ ├── PairList.java │ │ └── SimpleLinkList.java │ │ ├── BukkitUtils.java │ │ ├── ContainerUtils.java │ │ ├── CraftUtils.java │ │ ├── DataCache.java │ │ ├── Debug.java │ │ ├── MachineRecipeUtils.java │ │ ├── MathUtils.java │ │ ├── MenuUtils.java │ │ ├── NMSUtils.java │ │ ├── PdcUtils.java │ │ ├── ReflectUtils.java │ │ ├── Settings.java │ │ ├── TransportUtils.java │ │ ├── UtilClass │ │ ├── CargoClass │ │ │ ├── CargoConfigs.java │ │ │ ├── ContainerBlockMenuWrapper.java │ │ │ └── Directions.java │ │ ├── CommandClass │ │ │ ├── AddonCommand.java │ │ │ ├── CommandShell.java │ │ │ ├── ExportAddons.java │ │ │ └── LogitechMain.java │ │ ├── EffectClass │ │ │ ├── AbstractEffect.java │ │ │ └── PlayerEffects.java │ │ ├── EntityClass │ │ │ ├── DisplayBuilder.java │ │ │ ├── ItemDisplayBuilder.java │ │ │ └── TransformationBuilder.java │ │ ├── EquipClass │ │ │ └── EquipmentFU.java │ │ ├── FunctionalClass │ │ │ ├── AsyncResultRunnable.java │ │ │ ├── Counter.java │ │ │ ├── LoreDecorator.java │ │ │ ├── OutputStream.java │ │ │ └── StringDecorator.java │ │ ├── ItemClass │ │ │ ├── AbstractItemStack.java │ │ │ ├── AllMatchItem.java │ │ │ ├── ConstItemStack.java │ │ │ ├── ConstSlimefunItemStack.java │ │ │ ├── DisplayItemStack.java │ │ │ ├── EqProRandomStack.java │ │ │ ├── EquivalItemStack.java │ │ │ ├── HandledItemStack.java │ │ │ ├── ItemConsumer.java │ │ │ ├── ItemCounter.java │ │ │ ├── ItemGreedyConsumer.java │ │ │ ├── ItemPusher.java │ │ │ ├── ItemPusherProvider.java │ │ │ ├── ItemReplacerPusher.java │ │ │ ├── ItemSlotPusher.java │ │ │ ├── MultiItemStack.java │ │ │ ├── ProbItemStack.java │ │ │ ├── RandAmountStack.java │ │ │ ├── RandOutItem.java │ │ │ └── RandomItemStack.java │ │ ├── MenuClass │ │ │ ├── CustomItemGroup.java │ │ │ ├── CustomMenu.java │ │ │ ├── CustomMenuHandler.java │ │ │ ├── DataMenuClickHandler.java │ │ │ ├── DummyItemGroup.java │ │ │ ├── GuideCustomMenu.java │ │ │ ├── GuideMenuHandler.java │ │ │ ├── MenuFactory.java │ │ │ ├── MenuPreset.java │ │ │ ├── PlayerHistoryRecord.java │ │ │ └── SimplePlayerHistoryRecord.java │ │ ├── MultiBlockClass │ │ │ ├── AbstractMultiBlock.java │ │ │ ├── AbstractMultiBlockHandler.java │ │ │ ├── AbstractMultiBlockType.java │ │ │ ├── CubeMultiBlock │ │ │ │ ├── CubeMultiBlock.java │ │ │ │ └── CubeMultiBlockType.java │ │ │ ├── DisplayGroup.java │ │ │ ├── MultiBlock.java │ │ │ ├── MultiBlockHandler.java │ │ │ ├── MultiBlockService.java │ │ │ ├── MultiBlockType.java │ │ │ └── MultiLevelBlock │ │ │ │ ├── MultiLevelBlock.java │ │ │ │ └── MultiLevelBlockType.java │ │ ├── PdcClass │ │ │ ├── AbstractStorageType.java │ │ │ └── AbstractStringList.java │ │ ├── RecipeClass │ │ │ ├── CustomMachineOperation.java │ │ │ ├── EnergyProviderOperation.java │ │ │ ├── ImportRecipes.java │ │ │ ├── MGeneratorRecipe.java │ │ │ ├── MultiCraftingOperation.java │ │ │ ├── RandomMachineOperation.java │ │ │ ├── SequenceCraftingOperation.java │ │ │ ├── SequenceMachineRecipe.java │ │ │ ├── ShapedMachineRecipe.java │ │ │ ├── SimpleCraftingOperation.java │ │ │ ├── StackMachineRecipe.java │ │ │ └── TimeCounterOperation.java │ │ ├── SpecialItemClass │ │ │ ├── CustomFireworkStar.java │ │ │ └── CustomHead.java │ │ ├── StorageClass │ │ │ ├── ItemStorageCache.java │ │ │ ├── LocationProxy.java │ │ │ ├── LocationStorageProxy.java │ │ │ ├── LocationStorageProxyOld.java │ │ │ └── StorageType.java │ │ ├── TestItemStack.java │ │ └── TickerClass │ │ │ ├── PublicTicking.java │ │ │ ├── SyncBlockTick.java │ │ │ └── Ticking.java │ │ ├── Utils.java │ │ └── WorldUtils.java └── resources │ ├── addon-machines.yml │ ├── config.yml │ ├── item-settings.yml │ ├── language.yml │ ├── machines.yml │ ├── plugin.yml │ └── space-storage.yml └── test └── java └── me └── matl114 └── logitech ├── TestConsumer.java ├── TestCounter.java ├── TestPusher.java ├── TestSlotPusher.java ├── TestStack.java └── Tests.java /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /.settings/ 3 | /target/ 4 | .idea/ 5 | *.iml 6 | .project 7 | .classpath 8 | .DS_Store 9 | workspace.xml 10 | .gitignore 11 | .idea/* 12 | .idea 13 | log.txt 14 | /startServer.bat -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LogiTech (逻辑工艺 插件版) 2 | 3 | 这是matl114的第一个粘液科技插件附属项目 4 | 5 | this is matl114's first Slimefun addon project 6 | 7 | ## Installation (安装事项) 8 | 9 | 本附属有若干软依赖附属,我建议服务器安装他们以启用相关的特性 10 | 11 | this addon has soft depends ,I recommend installing them to enable related feature 12 | 13 | ### Soft Depends (附属软依赖) 14 | ``` 15 | - InfinityExpansion 16 | - Networks (Networks vExpansion) 17 | ``` 18 | 19 | 在此提供网络拓展的链接: https://github.com/ytdd9527/NetworksExpansion 20 | 21 | Network vExpansion repository: https://github.com/ytdd9527/NetworksExpansion 22 | 23 | 因网络拓展版本变动关系,部分特性不保证稳定加载 24 | 25 | Due to the change of Network vExpansion version,I don't guarantee all related features will be sucessfully enabled 26 | 27 | ## 关于LogiTECH 28 | ### 我们的目标 29 | 30 | LogiTech (逻辑工艺 插件版) 是一款区别于LogicTech(逻辑工艺)而存在的附属 31 | 32 | 冗长的SlimeCustomizer配置文件和重复功能的机器对服务器并没有好处,相反他让粘液科技变得过于城市化 33 | 34 | 故我们放弃开发LogicTech而开发LogiTech 35 | 36 | 该附属旨在让粘液变得更加抽象,在享受推进度的乐趣同时获得高生产力 37 | 38 | ### 我们的实现方式 39 | 40 | 我们附属开发了一些特性,我想有一些会帮助玩家更好的游戏 41 | 42 | - 堆叠机器 ,即 将机器成组放入堆叠机器 可以获得带倍率的产速 43 | - 终极合成机制, 无上限的合成数量,搭配对存储物品(量子存储,本附属的存储)直接操作的支持, 体验数值的爽感 44 | (指 合成进程可以直接大规模消耗存储里的东西进行合成,产出也可以大规模的输入存储中 45 | - 大型多方块结构机器 ,模组风格的多方块机器,让玩家重新找回科技的快乐 46 | - 复杂但不冗长的合成配方,搭配一键放置式的懒狗工作台 47 | - 各种奇妙机制的机器, 给予玩家独特体验 48 | - 由作者完全重构的机器实现,作者将为所有性能问题负责。 49 | - 更多的特性静待开发! 50 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/AbstractBlock.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.core.CustomSlimefunItem; 7 | import me.matl114.logitech.core.DistinctiveCustomSlimefunItem; 8 | import me.matl114.logitech.core.Interface.MenuBlock; 9 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | /** 13 | * abstracts of unclassified sf blocks 14 | */ 15 | public class AbstractBlock extends CustomSlimefunItem implements MenuBlock { 16 | public AbstractBlock(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 17 | super(itemGroup, item, recipeType, recipe); 18 | } 19 | public void addInfo(ItemStack stack){ 20 | 21 | } 22 | public void constructMenu(BlockMenuPreset preset){ 23 | 24 | } 25 | public int[] getInputSlots(){ 26 | return new int[0]; 27 | } 28 | public int[] getOutputSlots(){ 29 | return new int[0]; 30 | } 31 | public void preRegister() { 32 | super.preRegister(); 33 | this.handleBlock(this); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/MultiBlock/SmithWorkShop/InterfacedSmithTableTrimmer.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks.MultiBlock.SmithWorkShop; 2 | 3 | import me.matl114.matlib.algorithms.dataStructures.struct.Triplet; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.bukkit.inventory.RecipeChoice; 6 | import org.bukkit.inventory.SmithingInventory; 7 | 8 | public interface InterfacedSmithTableTrimmer { 9 | //can have multi output/like unequip/return empty trimmer 10 | //return the Triple 11 | public Triplet getTrimmedResult(SmithingInventory inventory); 12 | public RecipeChoice getTrimmerRecipeChoice(); 13 | public RecipeChoice getBaseRecipeChoice(); 14 | public RecipeChoice getExtraRecipeChoice(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/MultiBlock/SmithWorkShop/SWAmplifyComponent.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks.MultiBlock.SmithWorkShop; 2 | 3 | import com.google.common.base.Preconditions; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import lombok.Getter; 8 | import me.matl114.logitech.core.Items.Abstracts.MaterialItem; 9 | import me.matl114.logitech.utils.AddUtils; 10 | import me.matl114.logitech.utils.Utils; 11 | import org.bukkit.Material; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import java.util.HashMap; 15 | 16 | public class SWAmplifyComponent extends MaterialItem { 17 | static HashMap materialJudgement=new HashMap<>(); 18 | @Getter 19 | private Material type; 20 | public SWAmplifyComponent(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 21 | super(itemGroup, item, recipeType, recipe); 22 | Preconditions.checkArgument(!materialJudgement.containsKey(item.getType()),"Material of these Component must differ from each other for better judgement performance"); 23 | this.type=item.getType(); 24 | materialJudgement.put(item.getType(), this); 25 | this.setDisplayRecipes(Utils.list( 26 | AddUtils.getInfoShow("&f机制", 27 | "&7插入至锻铸工坊核心", 28 | "&7对四周的工坊接口产生增幅"), 29 | this.getItem().clone() 30 | )); 31 | 32 | } 33 | public static SWAmplifyComponent getComponentType(ItemStack item){ 34 | return item==null?null: materialJudgement.get(item.getType()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/MultiBlock/SmithWorkShop/SmithInterfaceCraftingLogic.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks.MultiBlock.SmithWorkShop; 2 | 3 | public class SmithInterfaceCraftingLogic { 4 | public static void inti(){ 5 | 6 | } 7 | 8 | static { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/MultiBlockCore/MultiBlockPart.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks.MultiBlockCore; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 6 | import me.matl114.logitech.listeners.Listeners.BlockOpenListener; 7 | import me.matl114.logitech.utils.UtilClass.MultiBlockClass.MultiBlockService; 8 | import me.matl114.logitech.utils.UtilClass.TickerClass.Ticking; 9 | import org.bukkit.event.Event; 10 | import org.bukkit.event.block.BlockBreakEvent; 11 | import org.bukkit.inventory.EquipmentSlot; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import javax.annotation.ParametersAreNonnullByDefault; 15 | import java.util.List; 16 | 17 | public interface MultiBlockPart extends Ticking { 18 | public String getPartId(); 19 | default boolean redirectMenu(){ 20 | return true; 21 | } 22 | //you must add handle menu to preRegister in order to handle MultiBlockPart 23 | default void onMultiBlockBreak(BlockBreakEvent e) { 24 | String uid= MultiBlockService.safeGetUUID(e.getBlock().getLocation()); 25 | MultiBlockService.deleteMultiBlock(uid, MultiBlockService.MultiBlockBreakCause.get(e.getBlock())); 26 | } 27 | 28 | /** 29 | * we override the handleBlock in @MenuBlock ,invoke this method in preRegister! 30 | * @param it 31 | */ 32 | default void handleMultiBlockPart(SlimefunItem it){ 33 | it.addItemHandler(new BlockBreakHandler(false, false) { 34 | @ParametersAreNonnullByDefault 35 | public void onPlayerBreak(BlockBreakEvent e, ItemStack itemStack, List list) { 36 | MultiBlockPart.this.onMultiBlockBreak(e); 37 | } 38 | }); 39 | } 40 | default void onMenuRedirect(PlayerRightClickEvent event) { 41 | boolean itemUsed = event.getHand() == EquipmentSlot.OFF_HAND; 42 | 43 | 44 | if (!itemUsed && event.useBlock() != Event.Result.DENY && !BlockOpenListener.rightClickBlock(event)) { 45 | return; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/MultiBlockCore/MultiCore.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks.MultiBlockCore; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import lombok.Setter; 8 | import me.matl114.logitech.utils.DataCache; 9 | import me.matl114.logitech.utils.UtilClass.MultiBlockClass.AbstractMultiBlockType; 10 | import me.matl114.logitech.utils.UtilClass.MultiBlockClass.MultiBlockService; 11 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 12 | import org.bukkit.Location; 13 | import org.bukkit.block.Block; 14 | import org.bukkit.inventory.ItemStack; 15 | 16 | public abstract class MultiCore extends MultiPart implements MultiBlockCore { 17 | 18 | public MultiCore(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, 19 | ItemStack[] recipe, String blockId){ 20 | super(itemGroup, item, recipeType, recipe, blockId); 21 | 22 | } 23 | public abstract MultiBlockService.MultiBlockBuilder getBuilder(); 24 | public abstract AbstractMultiBlockType getMultiBlockType(); 25 | @Setter 26 | protected boolean autoBuildDefault=true; 27 | public final void tick(Block b, BlockMenu menu,SlimefunBlockData data, int tickCount){ 28 | //in this case .blockMenu is null? 29 | Location loc=b.getLocation(); 30 | if(preCondition(b,menu,data)){ 31 | int autoCode=DataCache.getCustomData(data,MultiBlockService.getAutoKey(),autoBuildDefault?1:0); 32 | if(MultiBlockService.acceptCoreRequest(loc,getBuilder(),getMultiBlockType())){ 33 | runtimeCheck(menu.getLocation(),data,autoCode); 34 | processCore(b,menu); 35 | }else{ 36 | if(autoCode>0){ 37 | autoBuild(loc,data,autoCode); 38 | } 39 | } 40 | } 41 | process(b,menu,data); 42 | } 43 | public boolean preCondition(Block b,BlockMenu inv,SlimefunBlockData data){ 44 | return true; 45 | } 46 | public boolean redirectMenu(){ 47 | return false; 48 | } 49 | public void processCore(Block b, BlockMenu menu){ 50 | //doing nothing 51 | } 52 | public void preRegister(){ 53 | this.registerBlockMenu(this); 54 | this.registerTick(this); 55 | } 56 | public boolean isSync(){ 57 | return false; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/MultiBlockCore/MultiPart.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks.MultiBlockCore; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.core.Blocks.AbstractBlock; 8 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 9 | import org.bukkit.Location; 10 | import org.bukkit.block.Block; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | public class MultiPart extends AbstractBlock implements MultiBlockPart { 14 | public final String BLOCKID; 15 | public MultiPart(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String blockId) { 16 | super(itemGroup, item, recipeType, recipe); 17 | this.BLOCKID = blockId; 18 | } 19 | public String getPartId(){ 20 | return BLOCKID; 21 | } 22 | public boolean redirectMenu(){ 23 | return true; 24 | } 25 | 26 | public void tick(Block b,BlockMenu menu,int tickCount) { 27 | //donig nothing 28 | } 29 | public void processPart(Block b, BlockMenu menu,Location core){ 30 | //doing nothing 31 | } 32 | public void process(Block b, BlockMenu menu, SlimefunBlockData data){ 33 | //doing nothing 34 | } 35 | public void preRegister(){ 36 | // if(redirectMenu()){ 37 | // this.addHandler((BlockUseHandler)this::onMenuRedirect); 38 | // } 39 | super.preRegister(); 40 | handleMultiBlockPart(this); 41 | // registerTick(this); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Blocks/WitherProofBlock.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Blocks; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; 7 | import org.bukkit.block.Block; 8 | import org.bukkit.entity.Wither; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import javax.annotation.Nonnull; 12 | 13 | public class WitherProofBlock extends AbstractBlock implements WitherProof { 14 | public WitherProofBlock(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 15 | super(itemGroup, item, recipeType, recipe); 16 | } 17 | public void onAttack(@Nonnull Block var1, @Nonnull Wither var2){ 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/CargoMachine/AbstractSyncTickCargo.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.CargoMachine; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 7 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 8 | import me.matl114.logitech.core.Blocks.AbstractBlock; 9 | import me.matl114.logitech.utils.Settings; 10 | import me.matl114.logitech.utils.UtilClass.TickerClass.SyncBlockTick; 11 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 12 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 13 | import org.bukkit.block.Block; 14 | import org.bukkit.inventory.ItemStack; 15 | 16 | /** 17 | * controlled by sync tick and chip code to perform certain sequence task 18 | */ 19 | public abstract class AbstractSyncTickCargo extends AbstractBlock implements SyncBlockTick.SyncTickers { 20 | public static SyncBlockTick CARGO_SYNC_INSTANCE =new SyncBlockTick(); 21 | public static SyncBlockTick CHIP_SYNC =new SyncBlockTick(){ 22 | public void tick(Block b, SlimefunItem item, SlimefunBlockData data) { 23 | if(this.tickCount%2==0)return; 24 | if(item instanceof SyncTickers){ 25 | ((SyncTickers)item).syncTick(b,data.getBlockMenu(),data,this.tickCount/2); 26 | } 27 | } 28 | }; 29 | 30 | public AbstractSyncTickCargo(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 31 | super(itemGroup, item, recipeType, recipe); 32 | } 33 | public abstract int[] getInputSlots(); 34 | public abstract int[] getOutputSlots(); 35 | public abstract void constructMenu(BlockMenuPreset preset); 36 | public abstract void newMenuInstance(BlockMenu menu,Block b); 37 | public abstract void updateMenu(BlockMenu blockMenu, Block block, Settings mod); 38 | public abstract void syncTick(Block b, BlockMenu inv, SlimefunBlockData data, int synTickCount); 39 | public void preRegister(){ 40 | super.preRegister(); 41 | this.registerBlockMenu(this); 42 | this.handleBlock(this); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/CargoMachine/BiFilter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.CargoMachine; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 7 | import org.bukkit.Material; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | public class BiFilter extends AbstractFilter{ 11 | protected final int[] INPUT_BORDER=new int[]{ 12 | 0,1,2,3,4,5,6,7,8 13 | }; 14 | protected final int[] INPUT_SLOTS=new int[]{ 15 | 9,10,11,12,13,14,15,16,17 16 | }; 17 | protected final int[] BORDER=new int[]{ 18 | 18,19,20,21,22,23,24,25,26,27,29,30,32,33,35,36,38,39,41,42,44,45,47,48,50,51,53 19 | }; 20 | 21 | protected final int[] OUTPUT_BORDER=new int[]{ 22 | 37,40,43 23 | }; 24 | protected final ItemStack[] OUTPUT_BORDERS_ITEM=new ItemStack[]{ 25 | new CustomItemStack(Material.ORANGE_STAINED_GLASS_PANE,"&6槽位0","&7上方为输出槽0","&7下方为白名单槽0"), 26 | new CustomItemStack(Material.ORANGE_STAINED_GLASS_PANE,"&6默认槽位","&7上方为默认输出槽","&7下方为输入槽清空模式切换按钮"), 27 | new CustomItemStack(Material.ORANGE_STAINED_GLASS_PANE,"&6槽位0","&7上方为输出槽0","&7下方为白名单槽0") 28 | }; 29 | protected final int[] OUTPUT_SLOTS=new int[]{ 30 | 28,34,31 31 | }; 32 | protected final int[] OUTPUT_WLSLOTS=new int[]{ 33 | 46,52 34 | }; 35 | protected final int TRASH_SLOT=49; 36 | public BiFilter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 37 | super(itemGroup, item, recipeType, recipe); 38 | } 39 | public int[] getInputSlots(){ 40 | return INPUT_SLOTS; 41 | } 42 | public int[] getOutputSlots(){ 43 | return OUTPUT_SLOTS; 44 | } 45 | public int[] getOutputWLSlot(){ 46 | return OUTPUT_WLSLOTS; 47 | } 48 | public int getTrashSlot(){ 49 | return TRASH_SLOT; 50 | } 51 | public int[] getInputBorders(){ 52 | return INPUT_BORDER; 53 | } 54 | public int[] getBorders(){ 55 | return BORDER; 56 | } 57 | public int[] getOutputBorders(){ 58 | return OUTPUT_BORDER; 59 | } 60 | public ItemStack[] getOutputBordersItem(){ 61 | return OUTPUT_BORDERS_ITEM; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/CargoMachine/QuantumTrashCan.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.CargoMachine; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.utils.Settings; 8 | import me.matl114.logitech.utils.UtilClass.ItemClass.ItemPusher; 9 | import me.matl114.logitech.utils.UtilClass.StorageClass.ItemStorageCache; 10 | import me.matl114.logitech.core.Machines.Abstracts.AbstractMachine; 11 | import me.matl114.logitech.core.Registries.FinalFeature; 12 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 13 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 14 | import org.bukkit.block.Block; 15 | import org.bukkit.inventory.ItemStack; 16 | 17 | import java.util.stream.IntStream; 18 | 19 | public class QuantumTrashCan extends AbstractMachine { 20 | /** 21 | * constructor of abstractMachines will keep Collections of MachineRecipes,will register energyNetwork params, 22 | * will set up menu by overriding constructMenu method 23 | * 24 | * @param category 25 | * @param item 26 | * @param recipeType 27 | * @param recipe 28 | * @param energybuffer 29 | * @param energyConsumption 30 | */ 31 | protected int[] QUANTUM_SLOT = IntStream.range(0,9).toArray(); 32 | public QuantumTrashCan(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 33 | super(category, item, recipeType, recipe, 0,0); 34 | } 35 | 36 | @Override 37 | public void constructMenu(BlockMenuPreset preset) { 38 | preset.setSize(9); 39 | } 40 | 41 | @Override 42 | public int[] getInputSlots() { 43 | return new int[0]; 44 | } 45 | 46 | @Override 47 | public int[] getOutputSlots() { 48 | return new int[0]; 49 | } 50 | 51 | @Override 52 | public void process(Block b, BlockMenu preset, SlimefunBlockData data) { 53 | for (int slot : QUANTUM_SLOT) { 54 | ItemStack stack = preset.getItemInSlot(slot); 55 | if(stack ==null)continue; 56 | ItemPusher counter = FinalFeature.STORAGE_AND_LOCPROXY_READER.get(Settings.INPUT,stack,slot); 57 | if(counter instanceof ItemStorageCache proxy && proxy.getAmount()!=0){ 58 | proxy.setAmount(0); 59 | proxy.updateMenu(preset); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/CargoMachine/TrashCan.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.CargoMachine; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.core.Machines.Abstracts.AbstractMachine; 8 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 9 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 10 | import org.bukkit.block.Block; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.stream.IntStream; 14 | 15 | public class TrashCan extends AbstractMachine { 16 | protected final int[] INPUT_SLOTS= IntStream.rangeClosed(0, 53).toArray(); 17 | protected final int[] OUTPUT_SLOTS= new int[0]; 18 | public int[] getInputSlots(){ 19 | return INPUT_SLOTS; 20 | } 21 | public int[] getOutputSlots(){ 22 | return OUTPUT_SLOTS; 23 | } 24 | public TrashCan(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 25 | super(category,item,recipeType,recipe,0,0); 26 | } 27 | public void constructMenu(BlockMenuPreset preset){ 28 | preset.setSize(54); 29 | } 30 | 31 | public void process(Block b, BlockMenu preset, SlimefunBlockData data){ 32 | 33 | } 34 | public void tick(Block b, BlockMenu menu, SlimefunBlockData data, int ticker) { 35 | //Schedules.launchSchedules(()->{ 36 | int[] slots=getInputSlots(); 37 | ItemStack it; 38 | for(int i=0; i displayList) { 13 | super(itemGroup, item, recipeType, recipe, displayList); 14 | setDisplayRecipes( 15 | Utils.list(AddUtils.getInfoShow("&f机制", 16 | "&7这是一个智能货运机器", 17 | "&7智能货运机器的行为会包括若干对源方块和目标方块", 18 | "&7智能货运机器会进行从源方块到目标方块的物流传输", 19 | "&7智能货运机器支持目标方块设置的输入槽限制", 20 | "&7但是相应的,其最大传输量会被限制为min(576,配置数)" 21 | ),null, 22 | AddUtils.getInfoShow("&f机制", 23 | "&7本机器可以选择与其相邻的方块参与传输"),null 24 | ) 25 | ); 26 | this.transportSmarter=true; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/Transportation/CargoPipe.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.Transportation; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.core.Machines.Electrics.AbstractPipe; 7 | import me.matl114.logitech.utils.ContainerUtils; 8 | import me.matl114.logitech.utils.UtilClass.CargoClass.CargoConfigs; 9 | import org.bukkit.Location; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import java.util.HashSet; 13 | 14 | public class CargoPipe extends AbstractPipe { 15 | public CargoPipe(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe){ 16 | super(category, item, recipeType, recipe); 17 | } 18 | 19 | @Override 20 | public boolean avalibleDestination(Location toLocation) { 21 | // if(DataCache.getMenu(toLocation) != null){ 22 | // return true; 23 | // }else { 24 | // return false; 25 | // } 26 | //for vanilla chests 27 | return true; 28 | } 29 | 30 | private int configCode=CargoConfigs.getDefaultConfig(); 31 | @Override 32 | public void transfer(Location from, Location to) { 33 | ContainerUtils.transferWithContainer(from,to,this.configCode,new HashSet<>(),false); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/Transportation/LineCargoPlus.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.Transportation; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.utils.*; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import java.util.List; 10 | 11 | public class LineCargoPlus extends LineCargo { 12 | public LineCargoPlus(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayList) { 13 | super(itemGroup, item, recipeType, recipe, displayList); 14 | setDisplayRecipes( 15 | Utils.list(AddUtils.getInfoShow("&f机制", 16 | "&7这是一个智能货运机器", 17 | "&7智能货运机器的行为会包括若干对源方块和目标方块", 18 | "&7智能货运机器会进行从源方块到目标方块的物流传输", 19 | "&7智能货运机器支持目标方块设置的输入槽限制", 20 | "&7但是相应的,其最大传输量会被限制为min(576,配置数)" 21 | ),null, 22 | AddUtils.getInfoShow("&f机制", 23 | "&7本机器可以选择一个方向进行直线搜素", 24 | "&&搜索会在方块不存在方块菜单,或至最大搜索距离终止", 25 | "&7搜索最大距离为64", 26 | "&7在搜索链上的机器会向接下来的机器进行传输", 27 | "&7开启首位循环使搜索链上尾部机器向首部机器传输"),null 28 | ) 29 | ); 30 | this.transportSmarter=true; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/Transportation/RedstoneAdjacentCargo.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.Transportation; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.utils.*; 8 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 9 | import org.bukkit.block.Block; 10 | import org.bukkit.block.data.BlockData; 11 | import org.bukkit.block.data.Lightable; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import java.util.List; 15 | 16 | public class RedstoneAdjacentCargo extends AdjacentCargo { 17 | public RedstoneAdjacentCargo (ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayList) { 18 | super(itemGroup, item, recipeType, recipe, displayList); 19 | setDisplayRecipes( 20 | Utils.list(AddUtils.getInfoShow("&f机制", 21 | "&7这是一个可调控货运机器", 22 | "&7可调控货运机器的行为会包括若干对源方块和目标方块", 23 | "&7可调控货运机器会进行从源方块到目标方块的物流传输", 24 | "&7可调控货运机器会根据某些特定条件决定运输行为", 25 | "&7可调节货运机器支持目标方块设置的输入槽限制", 26 | "&7但是相应的,其最大传输量会被限制为min(576,配置数)" 27 | ),null, 28 | AddUtils.getInfoShow("&f机制", 29 | "&7本机器可以选择与其相邻的方块参与传输", 30 | "&7本机器接受红石信号的调控", 31 | "&7当该方块被充能时,进行正常推送", 32 | "&7当该方块不被充能时,待机", 33 | "&c红石信息的调控将有1sft(0.5s)延迟,当前刻更改的充能状态将在下一刻生效!"),null 34 | ) 35 | ); 36 | } 37 | public String POWERED_KEY="po"; 38 | public void cargoTask(Block b, BlockMenu menu, SlimefunBlockData data, int configCode){ 39 | BlockData data1=b.getBlockData(); 40 | if(data1 instanceof Lightable la&&la.isLit()){ 41 | super.cargoTask(b,menu,data,configCode); 42 | // DataCache.setCustomData(data,POWERED_KEY,la.isLit()?1:0); 43 | } 44 | } 45 | public boolean isSync(){ 46 | //run in sync thread can be faster 47 | return true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Cargo/Transportation/RemoteCargoPlus.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Cargo.Transportation; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.Language; 7 | import me.matl114.logitech.utils.*; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import java.util.List; 11 | 12 | public class RemoteCargoPlus extends RemoteCargo { 13 | public RemoteCargoPlus(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayList) { 14 | super(itemGroup, item, recipeType, recipe, displayList); 15 | setDisplayRecipes( 16 | Utils.list(AddUtils.getInfoShow("&f机制", 17 | "&7这是一个智能货运机器", 18 | "&7智能货运机器的行为会包括若干对源方块和目标方块", 19 | "&7智能货运机器会进行从源方块到目标方块的物流传输", 20 | "&7智能货运机器支持目标方块设置的输入槽限制", 21 | "&7但是相应的,其最大传输量会被限制为min(576,配置数)" 22 | ),null, 23 | AddUtils.getInfoShow("&f机制", 24 | "&7本机器可以选择任意方块参与传输", 25 | "将绑定目标方块的%s插入指定槽位以选择参与的方块".formatted(Language.get("Items.HYPER_LINK.Name"))),null 26 | ) 27 | ); 28 | this.transportSmarter=true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Depends/FinalTechAdapter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Depends; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | public class FinalTechAdapter { 8 | public static SlimefunItem storageCardInstance; 9 | public static Method finalTechUpdateLore=null; 10 | public static Method finalTechIsValidItem=null; 11 | public static boolean initSuccess=false; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/DistinctiveCustomSlimefunItem.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.core.attributes.DistinctiveItem; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.inventory.meta.ItemMeta; 9 | import org.bukkit.persistence.PersistentDataContainer; 10 | 11 | import javax.annotation.Nonnull; 12 | import java.util.List; 13 | 14 | /** 15 | * abstracts of should-compare special Slimefun items 16 | */ 17 | public abstract class DistinctiveCustomSlimefunItem extends CustomSlimefunItem implements DistinctiveItem { 18 | public DistinctiveCustomSlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayInfo) { 19 | super(itemGroup, item, recipeType, recipe, displayInfo); 20 | } 21 | 22 | public DistinctiveCustomSlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 23 | super(itemGroup, item, recipeType, recipe); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Interface/ChunkLimit.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Interface; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 4 | import me.matl114.logitech.utils.AddUtils; 5 | import me.matl114.logitech.utils.BukkitUtils; 6 | import me.matl114.logitech.utils.DataCache; 7 | import org.bukkit.Chunk; 8 | import org.bukkit.Location; 9 | 10 | import java.util.HashMap; 11 | import java.util.function.Consumer; 12 | 13 | public interface ChunkLimit { 14 | public HashMap getRecords(); 15 | default boolean onChunkPlace(Location location,Class instance){ 16 | Chunk chunk = location.getChunk(); 17 | Location loc=getRecords().get(chunk); 18 | if(loc==null||loc.equals(location)) { 19 | getRecords().put(chunk, location); 20 | return true; 21 | }else { 22 | SlimefunItem item=DataCache.getSfItem(loc); 23 | if(instance.isInstance(item)){ 24 | return false; 25 | }else{ 26 | getRecords().put(chunk, location); 27 | return true; 28 | } 29 | } 30 | } 31 | default boolean checkChunkPlace(Location location,Class instance){ 32 | Chunk chunk = location.getChunk(); 33 | Location loc=getRecords().get(chunk); 34 | if(loc==null||loc.equals(location)) { 35 | return true; 36 | }else { 37 | SlimefunItem item= DataCache.getSfItem(loc); 38 | if(instance.isInstance(item)){ 39 | return false; 40 | }else{ 41 | return true; 42 | } 43 | // if(item!=slimefunItem) { 44 | // return true; 45 | // }else{ 46 | // return false; 47 | // } 48 | } 49 | } 50 | default boolean onChunkBreak(Location location){ 51 | Chunk chunk = location.getChunk(); 52 | Location loc=getRecords().remove(chunk); 53 | return true; 54 | } 55 | default void onChunkReachLimit(Location location, SlimefunItem slimefunItem, Consumer outputStream){ 56 | BukkitUtils.executeSync(()->{ 57 | location.getWorld().strikeLightningEffect(location); 58 | outputStream.accept(AddUtils.resolveColor("&c不能在一个区块放置超过1个[%s]!".formatted(slimefunItem.getItem().getItemMeta().getDisplayName()))); 59 | DataCache.removeBlockData(location); 60 | }); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Interface/EnergyProvider.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Interface; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; 5 | import org.bukkit.Location; 6 | 7 | import javax.annotation.Nonnull; 8 | 9 | public interface EnergyProvider extends EnergyNetProvider { 10 | default boolean willExplode(@Nonnull Location l, @Nonnull SlimefunBlockData data) { 11 | return false; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Interface/MenuTogglableBlock.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Interface; 2 | 3 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 4 | 5 | public interface MenuTogglableBlock { 6 | // public int getToggleSlot(); 7 | public boolean[] getStatus(BlockMenu inv); 8 | public void toggleStatus(BlockMenu inv,boolean... result); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Interface/MultiCraftType.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Interface; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; 5 | import me.matl114.logitech.utils.DataCache; 6 | import org.bukkit.Location; 7 | 8 | public interface MultiCraftType extends RecipeLock { 9 | static int getRecipeTypeIndex(Location loc){ 10 | try{ 11 | String a= StorageCacheUtils.getData(loc,"craftType"); 12 | return Integer.parseInt(a); 13 | 14 | } catch (NumberFormatException a){ 15 | setRecipeTypeIndex(loc,-1); 16 | return -1; 17 | } 18 | } 19 | static int getRecipeTypeIndex(SlimefunBlockData data){ 20 | try{ 21 | String a= data.getData("craftType"); 22 | return Integer.parseInt(a); 23 | 24 | } catch (NumberFormatException a){ 25 | data.setData("craftType","-1"); 26 | return -1; 27 | } 28 | } 29 | 30 | /** 31 | * will not care about RecipeLock data 32 | * @param loc 33 | * @param val 34 | */ 35 | static void setRecipeTypeIndex(Location loc ,int val){ 36 | 37 | StorageCacheUtils.setData(loc, "craftType", String.valueOf(val)); 38 | } 39 | static void setRecipeTypeIndex(SlimefunBlockData data ,int val){ 40 | data.setData("craftType", String.valueOf(val)); 41 | } 42 | 43 | /** 44 | * if val not change ,will not clean RecipeLock data 45 | * @param loc 46 | * @param val 47 | */ 48 | static void safeSetRecipeTypeIndex(Location loc, int val){ 49 | int index=getRecipeTypeIndex(loc); 50 | if(index!=val){ 51 | forceSetRecipeTypeIndex(loc,val ); 52 | } 53 | } 54 | static void safeSetRecipeTypeIndex(SlimefunBlockData data, int val){ 55 | int index=getRecipeTypeIndex(data); 56 | if(index!=val){ 57 | forceSetRecipeTypeIndex(data,val ); 58 | } 59 | } 60 | 61 | /** 62 | * force clean RecipeLock data and save val 63 | * @param loc 64 | * @param val 65 | */ 66 | static void forceSetRecipeTypeIndex(Location loc, int val){ 67 | StorageCacheUtils.setData(loc, "craftType", String.valueOf(val)); 68 | DataCache.setLastRecipe(loc,-1); 69 | } 70 | static void forceSetRecipeTypeIndex(SlimefunBlockData data, int val){ 71 | data.setData("craftType", String.valueOf(val)); 72 | DataCache.setLastRecipe(data,-1); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Interface/RecipeLock.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Interface; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import me.matl114.logitech.utils.DataCache; 5 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 6 | import org.bukkit.Location; 7 | 8 | /** 9 | * this interface provides a restorer for recipe lock machinie ,selected recipe will only change if certain events occurs 10 | */ 11 | public interface RecipeLock { 12 | /** 13 | * representing the temp display item ,if not match to recipe index,change the existing display item 14 | * @param loc 15 | */ 16 | default int getNowRecordRecipe(Location loc){ 17 | //try{ 18 | return DataCache.getCustomData(loc,"record",-1); 19 | //return Integer.parseInt(a); 20 | 21 | // } catch (NumberFormatException a){ 22 | // setNowRecordRecipe(loc,-1); 23 | // return -1; 24 | // } 25 | } 26 | default int getNowRecordRecipe(SlimefunBlockData data){ 27 | return DataCache.getCustomData(data,"record",-1); 28 | // try{ 29 | // String a= data.getData("record"); 30 | // return Integer.parseInt(a); 31 | // 32 | // } catch (NumberFormatException a){ 33 | // data.setData("record","-1"); 34 | // return -1; 35 | // } 36 | } 37 | /** 38 | * representing the temp display item ,if not match to recipe index,change the existing display item 39 | * @param loc 40 | * @param val 41 | */ 42 | default void setNowRecordRecipe(Location loc ,int val){ 43 | 44 | DataCache.setCustomData(loc, "record", val); 45 | } 46 | default void setNowRecordRecipe(SlimefunBlockData data ,int val){ 47 | data.setData("record",String.valueOf(val)); 48 | } 49 | MachineRecipe getRecordRecipe(SlimefunBlockData data); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/ChargableProps.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | public abstract class ChargableProps extends CustomProps implements Rechargeable { 10 | public ChargableProps(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe){ 11 | super(itemGroup, item, recipeType, recipe); 12 | } 13 | public void addInfo(ItemStack stack){ 14 | super.addInfo(stack); 15 | setItemCharge(stack,0.0f); 16 | } 17 | public abstract float getMaxItemCharge(ItemStack var1); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/CustomArmorPiece.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | public class CustomArmorPiece extends CustomItemNotPlaceable { 9 | public CustomArmorPiece(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe){ 10 | super(itemGroup, item, recipeType, recipe); 11 | } 12 | public void addInfo(ItemStack itemStack){ 13 | super.addInfo(itemStack); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/CustomItemNotPlaceable.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; 7 | import me.matl114.logitech.core.CustomSlimefunItem; 8 | import me.matl114.logitech.core.Registries.AddHandlers; 9 | import me.matl114.logitech.utils.WorldUtils; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | /** 13 | * abstracts of weapons and armors 14 | */ 15 | public class CustomItemNotPlaceable extends CustomSlimefunItem implements NotPlaceable { 16 | public CustomItemNotPlaceable(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 17 | super(itemGroup, item, recipeType, recipe); 18 | } 19 | @Override 20 | public void preRegister(){ 21 | super.preRegister(); 22 | if(WorldUtils.isBlock(getItem().getType())){ 23 | addItemHandler(AddHandlers.stopPlacementHandler); 24 | addItemHandler(AddHandlers.stopPlaceerHandler); 25 | } 26 | 27 | } 28 | 29 | // @Override 30 | // public boolean canStack(@NotNull ItemMeta itemMeta, @NotNull ItemMeta itemMeta1) { 31 | // return false; 32 | // } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/CustomItemWithHandler.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.utils.WorldUtils; 8 | import me.matl114.logitech.core.Registries.AddHandlers; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import java.util.List; 12 | 13 | public abstract class CustomItemWithHandler extends FunctionalItem { 14 | public CustomItemWithHandler(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe){ 15 | super(itemGroup, item, recipeType, recipe); 16 | } 17 | public CustomItemWithHandler(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayes){ 18 | super(itemGroup, item, recipeType, recipe); 19 | setDisplayRecipes(displayes); 20 | } 21 | public abstract T[] getItemHandler(); 22 | public void preRegister(){ 23 | super.preRegister(); 24 | if(WorldUtils.isBlock(getItem().getType())){ 25 | addItemHandler(AddHandlers.stopPlacementHandler); 26 | addItemHandler(AddHandlers.stopPlaceerHandler); 27 | } 28 | addItemHandler(getItemHandler()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/CustomProps.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 8 | import me.matl114.matlib.utils.CraftUtils; 9 | import org.bukkit.inventory.ItemStack; 10 | import org.bukkit.inventory.meta.ItemMeta; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.util.List; 14 | 15 | public abstract class CustomProps extends CustomItemWithHandler { 16 | public CustomProps(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe){ 17 | super(itemGroup, item, recipeType, recipe); 18 | } 19 | public CustomProps(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayes){ 20 | super(itemGroup, item, recipeType, recipe); 21 | setDisplayRecipes(displayes); 22 | } 23 | /** 24 | * used for clickAction items 25 | */ 26 | public ItemUseHandler[] getItemHandler(){ 27 | return new ItemUseHandler[]{(ItemUseHandler) this::onClickAction}; 28 | } 29 | public abstract void onClickAction(PlayerRightClickEvent event); 30 | public void preRegister(){ 31 | super.preRegister(); 32 | 33 | } 34 | 35 | @Override 36 | public boolean canStack(@NotNull ItemMeta var1, @NotNull ItemMeta var2) { 37 | //most of them are weapons 38 | return var1.getPersistentDataContainer().equals(var2.getPersistentDataContainer()) && CraftUtils.matchLoreField(var1,var2) && CraftUtils.matchEnchantmentsFields(var1,var2) && me.matl114.logitech.utils.CraftUtils.matchAttrbuteField(var1,var2); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/DataRecordedItem.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.core.DistinctiveCustomSlimefunItem; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.inventory.meta.ItemMeta; 9 | import org.bukkit.persistence.PersistentDataContainer; 10 | 11 | import javax.annotation.Nonnull; 12 | import java.util.List; 13 | 14 | /** 15 | * item that contains important data in pdc, should always match pdc here 16 | */ 17 | public class DataRecordedItem extends DistinctiveCustomSlimefunItem { 18 | public DataRecordedItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayInfo) { 19 | super(itemGroup, item, recipeType, recipe, displayInfo); 20 | } 21 | public DataRecordedItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 22 | super(itemGroup, item, recipeType, recipe); 23 | } 24 | public boolean canStack(@Nonnull ItemMeta var1, @Nonnull ItemMeta var2){ 25 | 26 | PersistentDataContainer container1 = var1.getPersistentDataContainer(); 27 | PersistentDataContainer container2 = var2.getPersistentDataContainer(); 28 | return (container1.equals(container2)); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/FunctionalItem.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.core.DistinctiveCustomSlimefunItem; 7 | import me.matl114.matlib.utils.CraftUtils; 8 | import org.bukkit.inventory.ItemStack; 9 | import org.bukkit.inventory.meta.ItemMeta; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * functional items ,probably rechargable item/usable item/weapon 16 | * should check pdc,lore enchant attribute 17 | */ 18 | public class FunctionalItem extends DistinctiveCustomSlimefunItem { 19 | public FunctionalItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List displayInfo) { 20 | super(itemGroup, item, recipeType, recipe, displayInfo); 21 | } 22 | public FunctionalItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 23 | super(itemGroup, item, recipeType, recipe); 24 | } 25 | @Override 26 | public boolean canStack(@NotNull ItemMeta var1, @NotNull ItemMeta var2) { 27 | //most of them are weapons 28 | return var1.getPersistentDataContainer().equals(var2.getPersistentDataContainer()) && CraftUtils.matchLoreField(var1,var2) && CraftUtils.matchEnchantmentsFields(var1,var2) && me.matl114.logitech.utils.CraftUtils.matchAttrbuteField(var1,var2); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/MaterialItem.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; 8 | import me.matl114.logitech.core.Registries.AddHandlers; 9 | import me.matl114.logitech.core.CustomSlimefunItem; 10 | import me.matl114.logitech.utils.WorldUtils; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.List; 14 | 15 | public class MaterialItem extends CustomSlimefunItem implements NotPlaceable { 16 | public MaterialItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 17 | super(itemGroup, item, recipeType, recipe); 18 | this.checkCanStack=false; 19 | } 20 | public MaterialItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, List recipeDisplay) { 21 | super(itemGroup, item, recipeType, recipe,recipeDisplay); 22 | this.checkCanStack=false; 23 | } 24 | public void addInfo(ItemStack stack){ 25 | 26 | } 27 | @Override 28 | public void preRegister(){ 29 | super.preRegister(); 30 | //addItemHandler(AddHandlers.stopAttackHandler); 31 | if(WorldUtils.isBlock(getItem().getType())){ 32 | addItemHandler(AddHandlers.stopPlacementHandler); 33 | addItemHandler(AddHandlers.stopPlaceerHandler); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Abstracts/MyVanillaItem.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Abstracts; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; 7 | import me.matl114.logitech.core.AddSlimefunItems; 8 | import me.matl114.logitech.core.Interface.RecipeDisplay; 9 | import me.matl114.logitech.utils.AddUtils; 10 | import me.matl114.logitech.utils.Debug; 11 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | 18 | public class MyVanillaItem extends VanillaItem implements RecipeDisplay { 19 | List displayedMemory; 20 | public MyVanillaItem(ItemGroup itemGroup, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) { 21 | super(itemGroup, item, id, recipeType, recipe); 22 | this.useableInWorkbench = false; 23 | } 24 | public List provideDisplayRecipe(){ 25 | return new ArrayList<>(); 26 | } 27 | public final List getDisplayRecipes() { 28 | if(displayedMemory==null||displayedMemory.isEmpty()) { 29 | displayedMemory=_getDisplayRecipes(new ArrayList<>()); 30 | } 31 | return displayedMemory; 32 | } 33 | public MyVanillaItem addHandler(ItemHandler handler) { 34 | this.addItemHandler(handler); 35 | return this; 36 | } 37 | public MyVanillaItem setDisplayRecipes(List displayRecipes) { 38 | this.displayedMemory = displayRecipes; 39 | return this; 40 | } 41 | public MyVanillaItem addDisplayRecipe(ItemStack stack) { 42 | if(displayedMemory==null||displayedMemory.isEmpty()){ 43 | this.displayedMemory=new ArrayList<>(); 44 | } 45 | this.displayedMemory.add(stack); 46 | return this; 47 | } 48 | public MyVanillaItem setOutput(Object obj){ 49 | this.recipeOutput= AddUtils.resolveItem(obj); 50 | return this; 51 | } 52 | public MyVanillaItem register(){ 53 | if(AddSlimefunItems.INSTANCE!=null){ 54 | register(AddSlimefunItems.INSTANCE); 55 | }else{ 56 | Debug.logger("找不到附属实例! 注册信息: "+this.toString()); 57 | } 58 | return this; 59 | } 60 | public void postRegister(){ 61 | super.postRegister(); 62 | this.addWikiPage(""); 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Equipments/AntiGravityBar.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Equipments; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 8 | import me.matl114.logitech.core.Items.Abstracts.FunctionalItem; 9 | import me.matl114.logitech.core.Registries.CustomEffects; 10 | import me.matl114.logitech.utils.UtilClass.EffectClass.PlayerEffects; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | public class AntiGravityBar extends FunctionalItem { 14 | public AntiGravityBar(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 15 | super(itemGroup, item, recipeType, recipe); 16 | } 17 | public boolean onItemClick(PlayerRightClickEvent e){ 18 | 19 | PlayerEffects.grantEffect(CustomEffects.ANTI_GRAVITY,e.getPlayer(),1,10); 20 | return false; 21 | } 22 | public void preRegister(){ 23 | this.addHandler((ItemUseHandler)this::onItemClick); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/Equipments/DisplayUseTrimmerLogic.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.Equipments; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import me.matl114.logitech.core.Blocks.MultiBlock.SmithWorkShop.InterfacedSmithTableTrimmer; 6 | import me.matl114.logitech.core.Blocks.MultiBlock.SmithWorkShop.SmithInterfaceProcessor; 7 | import me.matl114.logitech.core.Items.Abstracts.MaterialItem; 8 | import me.matl114.matlib.algorithms.dataStructures.struct.Triplet; 9 | import org.bukkit.inventory.ItemStack; 10 | import org.bukkit.inventory.RecipeChoice; 11 | import org.bukkit.inventory.SmithingInventory; 12 | 13 | import java.util.function.Function; 14 | 15 | @Deprecated //not completed yet 16 | public class DisplayUseTrimmerLogic extends MaterialItem implements InterfacedSmithTableTrimmer { 17 | public DisplayUseTrimmerLogic(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] displayUse,RecipeChoice trim,RecipeChoice base, Function trimmerLogic) { 18 | super(itemGroup, item, SmithInterfaceProcessor.INTERFACED_SMITH_TRIM, displayUse); 19 | } 20 | 21 | @Override 22 | public Triplet getTrimmedResult(SmithingInventory inventory) { 23 | return null; 24 | } 25 | 26 | @Override 27 | public RecipeChoice getTrimmerRecipeChoice() { 28 | return null; 29 | } 30 | 31 | @Override 32 | public RecipeChoice getBaseRecipeChoice() { 33 | return null; 34 | } 35 | 36 | @Override 37 | public RecipeChoice getExtraRecipeChoice() { 38 | return null; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Items/SpecialItems/Singularity.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Items.SpecialItems; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.utils.AddUtils; 7 | import me.matl114.logitech.utils.Utils; 8 | import me.matl114.logitech.core.Items.Abstracts.DataRecordedItem; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public class Singularity extends DataRecordedItem { 12 | public Singularity(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 13 | super(itemGroup, item, recipeType, recipe); 14 | this.setDisplayRecipes( 15 | Utils.list( 16 | AddUtils.getInfoShow("&f机制 - &c终极合成", 17 | "&c特性 ", 18 | "&7终极合成是本附属某些终极机器中的机制", 19 | "&c具体说明请看\"版本与说明\"分类中的信息", 20 | "&7直白了说是让物品存储中的物品直接参与合成/进程", 21 | "&7从而打破槽位限制", 22 | "&7该物品是终极机器支持的物品之一", 23 | "&a建议:不推荐直接将存储奇点放入终极机器,不方便且会有更高卡顿!"), 24 | null, 25 | AddUtils.getInfoShow("&7机制 -&c 物品存储", 26 | "&7本物品可以存储某种物品", 27 | "&7本物品的最大存储量为2147483647", 28 | "&7当该物品被放入终极机器的槽位中时,", 29 | "&7可以代理其内部存储的物品&e直接参与合成!", 30 | "&7产出的物品也可以&e直接进入内部存储的物品中!", 31 | "&e本物品需要奇点交互接口才可以进行数量操作和种类设置"),null 32 | ) 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/Abstracts/AbstractEnergyProvider.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.Abstracts; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 7 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 8 | import me.matl114.logitech.core.Interface.EnergyProvider; 9 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 10 | import org.bukkit.Location; 11 | import org.bukkit.block.Block; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import javax.annotation.Nonnull; 15 | 16 | public abstract class AbstractEnergyProvider extends AbstractMachine implements EnergyProvider { 17 | public AbstractEnergyProvider(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 18 | int energyBuffer, int energyProvider) { 19 | super(category, item, recipeType, recipe, energyBuffer,-energyProvider); 20 | } 21 | public void process(Block b, BlockMenu inv, SlimefunBlockData data){ 22 | } 23 | public void registerTick(SlimefunItem item){ 24 | //no ticker 25 | } 26 | public abstract int getGeneratedOutput(@Nonnull Location l, @Nonnull SlimefunBlockData data); 27 | public void preRegister(){ 28 | super.preRegister(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/AutoMachines/AdvanceCrafter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.AutoMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import org.bukkit.Material; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import java.util.List; 10 | 11 | public class AdvanceCrafter { 12 | public List displayedMemory = null; 13 | protected final RecipeType[] craftType; 14 | public AdvanceCrafter(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, Material progressItem, 15 | int energybuffer, int energyConsumption, 16 | RecipeType... craftType) { 17 | //super(category,item,recipeType,recipe,progressItem,energybuffer,energyConsumption,null); 18 | this.craftType = craftType; 19 | } 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/AutoMachines/FinalMGenerator.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.AutoMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; 8 | import me.matl114.logitech.core.Registries.FinalFeature; 9 | import me.matl114.logitech.utils.AddUtils; 10 | import me.matl114.logitech.utils.Utils; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.List; 14 | 15 | public class FinalMGenerator extends MMGenerator{ 16 | public FinalMGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 17 | int time, int energybuffer, int energyConsumption, List> outputs_w){ 18 | super(itemGroup,item,recipeType,recipe,time,energybuffer,energyConsumption, 19 | outputs_w ); 20 | setDisplayRecipes( 21 | Utils.list( 22 | AddUtils.getInfoShow( 23 | "&f机制 - &c终极合成", 24 | "&7机器的输出槽支持终极合成的特性", 25 | "&e可以直接消耗存储类物品或者链接绑定的实体存储内的物品参与合成", 26 | "&e产出的物品也可以直接地存入存储类物品或者链接绑定的实体存储", 27 | "&7当前支持的物品:", 28 | "&7逻辑工艺 概念奇点存储(存储类物品)", 29 | "&7逻辑工艺 量子纠缠奇点(存储链接物品)", 30 | "&7网络(拓展) 量子存储系列(存储类物品)", 31 | "&a建议:多使用量子纠缠奇点,可以大幅度减少卡顿!" 32 | ),null 33 | ) 34 | ); 35 | this.CRAFT_PROVIDER= FinalFeature.STORAGE_AND_LOCPROXY_READER; 36 | } 37 | public void registerTick(SlimefunItem item){ 38 | this.addItemHandler(FinalFeature.FINAL_SYNC_TICKER); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/AutoMachines/FinalSequenceConstructor.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.AutoMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; 8 | import me.matl114.logitech.core.Registries.FinalFeature; 9 | import me.matl114.logitech.utils.AddUtils; 10 | import me.matl114.logitech.utils.Utils; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.List; 14 | 15 | public class FinalSequenceConstructor extends SequenceConstructor { 16 | public FinalSequenceConstructor(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 17 | ItemStack progressItem, int energyConsumption, int energyBuffer, 18 | List> customRecipes) { 19 | super(category,item,recipeType,recipe,progressItem,energyConsumption,energyBuffer,customRecipes); 20 | this.CRAFT_PROVIDER= FinalFeature.STORAGE_AND_LOCPROXY_READER; 21 | setDisplayRecipes( 22 | Utils.list( 23 | AddUtils.getInfoShow( 24 | "&f机制 - &c终极合成", 25 | "&7机器的输入槽,输出槽均支持终极合成的特性", 26 | "&e可以直接消耗存储类物品或者链接绑定的实体存储内的物品参与合成", 27 | "&e产出的物品也可以直接地存入存储类物品或者链接绑定的实体存储", 28 | "&7当前支持的物品:", 29 | "&7逻辑工艺 概念奇点存储(存储类物品)", 30 | "&7逻辑工艺 量子纠缠奇点(存储链接物品)", 31 | "&7网络(拓展) 量子存储系列(存储类物品)", 32 | "&a建议:多使用量子纠缠奇点,可以大幅度减少卡顿!" 33 | ),null 34 | ) 35 | ); 36 | } 37 | public void registerTick(SlimefunItem item){ 38 | this.addItemHandler(FinalFeature.FINAL_SYNC_TICKER); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/AutoMachines/FinalStackMGenerator.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.AutoMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.core.Registries.FinalFeature; 8 | import me.matl114.logitech.utils.AddUtils; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public class FinalStackMGenerator extends StackMGenerator { 12 | public FinalStackMGenerator(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 13 | int time, int energyBuffer, int energyConsumption, int efficiency) { 14 | super(category, item, recipeType, recipe,time, energyBuffer,energyConsumption, efficiency); 15 | this.CRAFT_PROVIDER= FinalFeature.STORAGE_AND_LOCPROXY_READER; 16 | this.MACHINE_PROVIDER=FinalFeature.STORAGE_READER; 17 | this.addDisplayRecipe( 18 | AddUtils.getInfoShow( 19 | "&f机制 - &c终极合成", 20 | "&7机器的输入槽,输出槽,机器槽均支持终极合成的特性", 21 | "&e可以直接消耗存储类物品或者链接绑定的实体存储内的物品参与合成", 22 | "&e产出的物品也可以直接地存入存储类物品或者链接绑定的实体存储", 23 | "&7当前支持的物品:", 24 | "&7逻辑工艺 概念奇点存储(存储类物品)", 25 | "&7逻辑工艺 量子纠缠奇点(存储链接物品)", 26 | "&7网络(拓展) 量子存储系列(存储类物品)", 27 | "&c机器槽中只能放入存储类物品!不能放入存储链接!", 28 | "&a建议:多使用量子纠缠奇点,可以大幅度减少卡顿!" 29 | ) 30 | ); 31 | this.addDisplayRecipe(null); 32 | } 33 | public void registerTick(SlimefunItem item){ 34 | this.addItemHandler(FinalFeature.FINAL_SYNC_TICKER); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/AutoMachines/FinalStackMachine.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.AutoMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.core.Registries.FinalFeature; 8 | import me.matl114.logitech.utils.AddUtils; 9 | import org.bukkit.Material; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | public class FinalStackMachine extends StackMachine{ 13 | public FinalStackMachine(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 14 | Material progressItem, int energyConsumption, int energyBuffer, double efficiency) { 15 | super(category, item, recipeType, recipe, progressItem, energyConsumption, energyBuffer, efficiency); 16 | AddUtils.addGlow(getProgressBar()); 17 | this.CRAFT_PROVIDER= FinalFeature.STORAGE_AND_LOCPROXY_READER; 18 | this.MACHINE_PROVIDER=FinalFeature.STORAGE_READER; 19 | this.addDisplayRecipe( 20 | AddUtils.getInfoShow( 21 | "&f机制 - &c终极合成", 22 | "&7机器的输入槽,输出槽,机器槽均支持终极合成的特性", 23 | "&e可以直接消耗存储类物品或者链接绑定的实体存储内的物品参与合成", 24 | "&e产出的物品也可以直接地存入存储类物品或者链接绑定的实体存储", 25 | "&7当前支持的物品:", 26 | "&7逻辑工艺 概念奇点存储(存储类物品)", 27 | "&7逻辑工艺 量子纠缠奇点(存储链接物品)", 28 | "&7网络(拓展) 量子存储系列(存储类物品)", 29 | "&c机器槽中只能放入存储类物品!不能放入存储链接!", 30 | "&a建议:多使用量子纠缠奇点,可以大幅度减少卡顿!" 31 | ) 32 | ); 33 | this.addDisplayRecipe(null); 34 | } 35 | public void registerTick(SlimefunItem item){ 36 | this.addItemHandler(FinalFeature.FINAL_SYNC_TICKER); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/AutoMachines/SequenceConstructor.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.AutoMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; 7 | import me.matl114.logitech.core.Machines.Abstracts.AbstractSequenceProcessor; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import java.util.List; 11 | 12 | public class SequenceConstructor extends AbstractSequenceProcessor { 13 | public SequenceConstructor(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 14 | ItemStack progressItem, int energyConsumption, int energyBuffer, 15 | List> customRecipes) { 16 | super(category,item,recipeType,recipe,progressItem,energyConsumption,energyBuffer,customRecipes); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/AutoMachines/SpecialTypeCrafter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.AutoMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.core.Registries.RecipeSupporter; 8 | import org.bukkit.Material; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import java.util.HashMap; 12 | import java.util.HashSet; 13 | 14 | public class SpecialTypeCrafter extends SpecialCrafter { 15 | @Override 16 | public HashMap getRecipeTypeMap() { 17 | return RecipeSupporter.CUSTOM_RECIPETYPES; 18 | } 19 | public boolean advanced(){ 20 | return false; 21 | } 22 | public SpecialTypeCrafter(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 23 | Material progressItem, int ticks, int energyConsumption, int energyBuffer, HashSet blackList){ 24 | super(category, item, recipeType, recipe, progressItem, ticks, energyConsumption, energyBuffer,blackList); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/Electrics/Capacitor.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.Electrics; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.core.Machines.Abstracts.AbstractMachine; 8 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 9 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 10 | import org.bukkit.block.Block; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | public class Capacitor extends AbstractMachine { 14 | public int[] getInputSlots(){ 15 | return new int[0]; 16 | } 17 | public int[] getOutputSlots(){ 18 | return new int[0]; 19 | } 20 | 21 | public Capacitor(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 22 | int energybuffer){ 23 | super(category,item,recipeType,recipe,energybuffer,0); 24 | } 25 | public void process(Block b, BlockMenu inv, SlimefunBlockData data){ 26 | } 27 | 28 | public void constructMenu(BlockMenuPreset preset){ 29 | 30 | } 31 | public void preRegister(){ 32 | registerTick(this); 33 | addInfo(this.getItem()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/Electrics/EGenerator.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.Electrics; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; 7 | import me.matl114.logitech.core.Machines.Abstracts.AbstractEnergyProcessor; 8 | import org.bukkit.Material; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import java.util.List; 12 | 13 | public class EGenerator extends AbstractEnergyProcessor { 14 | protected final int[] INPUT_SLOT=new int[]{ 15 | 19,20 16 | }; 17 | protected final int[] OUTPUT_SLOT=new int[]{ 18 | 24,25 19 | }; 20 | public int[] getInputSlots(){ 21 | return INPUT_SLOT; 22 | } 23 | public int[] getOutputSlots(){ 24 | return OUTPUT_SLOT; 25 | } 26 | public EGenerator(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, Material progressItem, 27 | int energyBuffer, int energyProvider, List> customRecipe) { 28 | super(category,item,recipeType,recipe,progressItem,energyBuffer,energyProvider,customRecipe); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/Electrics/EnergyIOStorage.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.Electrics; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; 7 | import me.matl114.logitech.core.Interface.EnergyProvider; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | public class EnergyIOStorage extends EnergyStorage implements EnergyProvider { 11 | public EnergyIOStorage(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 12 | int energybuffer){ 13 | super(category, item, recipeType, recipe, energybuffer, EnergyNetComponentType.GENERATOR); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/Electrics/EnergyTrash.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.Electrics; 2 | 3 | 4 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 5 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 7 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 8 | import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 9 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 10 | import org.bukkit.Location; 11 | import org.bukkit.block.Block; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import javax.annotation.Nonnull; 15 | 16 | public class EnergyTrash extends Capacitor { 17 | public EnergyTrash(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 18 | int energybuffer) { 19 | super(category, item, recipeType, recipe, energybuffer); 20 | } 21 | public void process(Block b, BlockMenu inv, SlimefunBlockData data){ 22 | } 23 | public void setCharge(@Nonnull Location l, int charge){ 24 | 25 | } 26 | public void removeCharge(@Nonnull Location l, int charge){ 27 | } 28 | public void addCharge(@Nonnull Location l, int charge){ 29 | } 30 | public int getCharge(@Nonnull Location l) { 31 | return 0; 32 | } 33 | 34 | /** @deprecated */ 35 | @Deprecated 36 | public int getCharge(@Nonnull Location l, @Nonnull Config config) { 37 | return 0; 38 | } 39 | 40 | public int getCharge(@Nonnull Location l, @Nonnull SlimefunBlockData data) { 41 | return 0; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/EmptyMachineSample.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines; 2 | 3 | import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.utils.Settings; 8 | import me.matl114.logitech.core.Machines.Abstracts.AbstractMachine; 9 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 10 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 11 | import org.bukkit.block.Block; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | public class EmptyMachineSample extends AbstractMachine { 15 | protected final int[] INPUT_SLOTS=new int[0]; 16 | protected final int[] OUTPUT_SLOTS=new int[0]; 17 | public int[] getInputSlots(){ 18 | return INPUT_SLOTS; 19 | } 20 | public int[] getOutputSlots(){ 21 | return OUTPUT_SLOTS; 22 | } 23 | 24 | public EmptyMachineSample(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 25 | int energybuffer, int energyConsumption){ 26 | super(category, item, recipeType, recipe, energybuffer, energyConsumption); 27 | } 28 | public void constructMenu(BlockMenuPreset preset){ 29 | 30 | } 31 | public void newMenuInstance(BlockMenu menu, Block block){ 32 | } 33 | public void updateMenu(BlockMenu menu, Block block, Settings mod){} 34 | public void process(Block b, BlockMenu menu, SlimefunBlockData data){} 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/ManualMachines/ManualCrafter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.ManualMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.manager.PostSetupTasks; 7 | import me.matl114.logitech.core.Machines.Abstracts.AbstractManual; 8 | 9 | import me.matl114.logitech.core.Registries.RecipeSupporter; 10 | import me.matl114.logitech.utils.UtilClass.RecipeClass.ImportRecipes; 11 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | public class ManualCrafter extends AbstractManual implements ImportRecipes { 18 | public List displayedMemory = null; 19 | protected final RecipeType[] craftType; 20 | public ManualCrafter(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 21 | int energybuffer, int energyConsumption, 22 | RecipeType... craftType) { 23 | super(category,item,recipeType,recipe,energybuffer,energyConsumption,null); 24 | this.craftType = craftType; 25 | this.machineRecipeSupplier=()->{ 26 | if(this.craftType==null||this.craftType.length<=0){ 27 | return new ArrayList<>(); 28 | } 29 | else { 30 | List recipes = new ArrayList<>(); 31 | for(RecipeType rt : this.craftType){ 32 | if(rt!=null) 33 | recipes.addAll(RecipeSupporter.PROVIDED_UNSHAPED_RECIPES.get(rt)); 34 | } 35 | return recipes; 36 | } 37 | }; 38 | PostSetupTasks.addPostRegisterTask(()->{ 39 | getDisplayRecipes(); 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/ManualMachines/ManualMachine.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.ManualMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.manager.PostSetupTasks; 7 | import me.matl114.logitech.core.Machines.Abstracts.AbstractManual; 8 | 9 | import me.matl114.logitech.utils.UtilClass.RecipeClass.ImportRecipes; 10 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.List; 14 | import java.util.function.Supplier; 15 | 16 | public class ManualMachine extends AbstractManual implements ImportRecipes { 17 | public List displayedMemory = null; 18 | public ManualMachine(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 19 | int energybuffer, int energyConsumption, 20 | Supplier> machineRecipeSupplier) { 21 | super(category,item,recipeType,recipe,energybuffer,energyConsumption,null); 22 | this.machineRecipeSupplier = machineRecipeSupplier; 23 | //开服之后加载配方 24 | PostSetupTasks.addPostRegisterTask(()->{ 25 | getDisplayRecipes(); 26 | }); 27 | } 28 | public void registerDefaultRecipes(){ 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/ManualMachines/PortableManual.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.ManualMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.matl114.logitech.core.AddSlimefunItems; 8 | import me.matl114.logitech.core.Items.Abstracts.CustomProps; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | public class PortableManual extends CustomProps { 13 | public PortableManual(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 14 | super(itemGroup, item, recipeType, recipe); 15 | } 16 | 17 | @Override 18 | public void onClickAction(PlayerRightClickEvent event) { 19 | event.cancel(); 20 | Player player = event.getPlayer(); 21 | if(AddSlimefunItems.ADV_MANUAL instanceof AdvancedManual adv){ 22 | adv.openManualGui(player); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/core/Machines/ManualMachines/RandOutManulCrafter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.core.Machines.ManualMachines; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import me.matl114.logitech.utils.AddUtils; 7 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public class RandOutManulCrafter extends ManualCrafter{ 12 | public RandOutManulCrafter(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 13 | int energybuffer, int energyConsumption, 14 | RecipeType... craftType) { 15 | super(category,item,recipeType,recipe,energybuffer,energyConsumption,craftType); 16 | } 17 | public boolean preCraft(BlockMenu inv, Player p,boolean sendMessage){ 18 | int[] outputs=getOutputSlots(); 19 | for (int i=0;i AXE_MATERIAL=new HashSet<>(){{ 20 | for(Material material : Material.values()){ 21 | if(material.toString().endsWith("_AXE")){ 22 | add(material); 23 | } 24 | } 25 | }}; 26 | HashSet SHIELD_MATERIAL=new HashSet<>(){{ 27 | for(Material material : Material.values()){ 28 | if(material.toString().endsWith("SHIELD")&&material.isItem()){ 29 | add(material); 30 | } 31 | } 32 | }}; 33 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 34 | public void onAttackUsingShield(EntityDamageByEntityEvent e){ 35 | if(e.getEntity() instanceof Player p){ 36 | if(e.getDamager() instanceof LivingEntity entity){ 37 | EntityEquipment eequipment = entity.getEquipment(); 38 | if(eequipment!=null&&(AXE_MATERIAL.contains( eequipment.getItemInMainHand().getType())||AXE_MATERIAL.contains(eequipment.getItemInOffHand().getType()))){ 39 | ItemStack stackInUse=p.getItemInUse(); 40 | if(stackInUse!=null&&SHIELD_MATERIAL.contains( stackInUse.getType()) && SlimefunItem.getByItem(stackInUse)== AddSlimefunItems.UNBREAKING_SHIELD){ 41 | Material type=stackInUse.getType(); 42 | Schedules.launchSchedules(()->{ 43 | if(p.hasCooldown(type)&&p.getCooldown(type)>0){ 44 | p.setCooldown(type,0); 45 | } 46 | },0,true,0); 47 | } 48 | } 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/CraftingListener.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import me.matl114.logitech.MyAddon; 4 | import org.bukkit.NamespacedKey; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.EventPriority; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.inventory.CraftItemEvent; 10 | import org.bukkit.event.inventory.PrepareItemCraftEvent; 11 | import org.bukkit.inventory.ShapedRecipe; 12 | 13 | import java.util.Locale; 14 | 15 | public class CraftingListener implements Listener { 16 | public static String AddonName= MyAddon.getInstance().getName().toLowerCase(Locale.ROOT); 17 | @EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = false) 18 | public void onCraft(CraftItemEvent e) { 19 | if(e.getRecipe() instanceof ShapedRecipe sr) { 20 | NamespacedKey key = sr.getKey(); 21 | if(AddonName.equals(key.getNamespace())) { 22 | e.setResult(Event.Result.ALLOW); 23 | e.getInventory().setResult(sr.getResult()); 24 | } 25 | } 26 | } 27 | @EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = false) 28 | public void onPrepareCraft(PrepareItemCraftEvent e) { 29 | if(e.getRecipe() instanceof ShapedRecipe sr) { 30 | NamespacedKey key = sr.getKey(); 31 | if(AddonName.equals(key.getNamespace())) { 32 | e.getInventory().setResult(sr.getResult()); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/LaserGunOnHeadListener.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 4 | import me.matl114.logitech.core.Items.Equipments.LaserGun; 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.PlayerSwapHandItemsEvent; 10 | import org.bukkit.inventory.EquipmentSlot; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | public class LaserGunOnHeadListener implements Listener { 14 | @EventHandler 15 | public void onPlayerSneakWithLaser(PlayerSwapHandItemsEvent event) { 16 | Player player = event.getPlayer(); 17 | ItemStack stack=player.getInventory().getItem(EquipmentSlot.HEAD); 18 | if(stack==null||stack.getType()!= Material.PLAYER_HEAD){ 19 | return; 20 | } 21 | SlimefunItem item=SlimefunItem.getByItem(stack); 22 | if(item instanceof LaserGun lg){ 23 | event.setCancelled(true); 24 | lg.onLaser(player,stack,true,false); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/MilkListener.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | package me.matl114.logitech.listeners.Listeners; 5 | 6 | import me.matl114.logitech.manager.EffectTickManager; 7 | import org.bukkit.Material; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.player.PlayerItemConsumeEvent; 12 | 13 | public class MilkListener implements Listener { 14 | 15 | @EventHandler 16 | public void onConsume(PlayerItemConsumeEvent e) { 17 | if (e.isCancelled()) { 18 | return; 19 | } 20 | 21 | Player player = e.getPlayer(); 22 | 23 | if (e.getItem().getType() == Material.MILK_BUCKET) { 24 | EffectTickManager.clearAllEffects(e.getPlayer()); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/PlayerInSolar.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import org.bukkit.event.Listener; 4 | import org.bukkit.event.entity.PlayerDeathEvent; 5 | 6 | public class PlayerInSolar implements Listener { 7 | public void onPlayerKilledBySolar(PlayerDeathEvent e) { 8 | 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/PlayerQuiteListener.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerKickEvent; 7 | import org.bukkit.event.player.PlayerQuitEvent; 8 | 9 | import java.util.HashSet; 10 | import java.util.function.Consumer; 11 | 12 | public class PlayerQuiteListener implements Listener { 13 | @EventHandler 14 | public void onPlayerQuit(PlayerQuitEvent e) { 15 | Player p = e.getPlayer(); 16 | for (Consumer handler:handlers){ 17 | handler.accept(p); 18 | } 19 | } 20 | @EventHandler 21 | public void onKick(PlayerKickEvent e) { 22 | Player p = e.getPlayer(); 23 | for (Consumer handler:handlers){ 24 | handler.accept(p); 25 | } 26 | } 27 | static HashSet> handlers = new HashSet<>(); 28 | public static void addHandler(Consumer handler) { 29 | synchronized (handlers) { 30 | handlers.add(handler); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/PotionClearOnDeath.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import me.matl114.logitech.manager.EffectTickManager; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.entity.PlayerDeathEvent; 7 | 8 | public class PotionClearOnDeath implements Listener { 9 | @EventHandler 10 | public void onPlayerDeath(PlayerDeathEvent e) { 11 | EffectTickManager.clearEffectsOnDeath(e); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/SlimefunBlockPlaceLimitListener.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockPlaceEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import me.matl114.logitech.MyAddon; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | 9 | import java.util.HashMap; 10 | import java.util.function.Consumer; 11 | 12 | public class SlimefunBlockPlaceLimitListener implements Listener { 13 | static HashMap> eventHandlers = new HashMap<>(); 14 | @EventHandler 15 | public void onBlockPlace(SlimefunBlockPlaceEvent event) { 16 | SlimefunItem item=event.getSlimefunItem(); 17 | if(item.getAddon()== MyAddon.getInstance()){ 18 | if(eventHandlers.containsKey(item)){ 19 | eventHandlers.get(item).accept(event); 20 | } 21 | } 22 | } 23 | public static void registerBlockLimit(SlimefunItem item, Consumer handler) { 24 | eventHandlers.put(item, handler); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/SmeltingListener.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import org.bukkit.event.Listener; 4 | 5 | public class SmeltingListener implements Listener { 6 | //if one day, we send recipes to furnace ,then we should add sth here 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/SpawnerListener.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfContainment; 4 | import me.matl114.logitech.core.Blocks.AbstractSpawner; 5 | import me.matl114.logitech.core.Items.SpecialItems.EntityFeat; 6 | import me.matl114.logitech.utils.AddUtils; 7 | import me.matl114.logitech.utils.CraftUtils; 8 | import me.matl114.logitech.utils.DataCache; 9 | import org.bukkit.Location; 10 | import org.bukkit.Material; 11 | import org.bukkit.block.Block; 12 | import org.bukkit.entity.EntityType; 13 | import org.bukkit.event.EventHandler; 14 | import org.bukkit.event.EventPriority; 15 | import org.bukkit.event.Listener; 16 | import org.bukkit.event.block.BlockBreakEvent; 17 | 18 | import java.util.Random; 19 | 20 | public class SpawnerListener implements Listener { 21 | private Random rand=new Random(); 22 | private final EntityType[] entityTypes=EntityType.values(); 23 | protected int chance=50; 24 | //move priority to HIGH to avoid sf block break listener set Drop false 25 | @EventHandler(priority = EventPriority.HIGH,ignoreCancelled = true) 26 | public void onSpawnerBreak(BlockBreakEvent event) { 27 | //drop entity feat 28 | Block b=event.getBlock(); 29 | //avoid fake event 30 | if(event.isDropItems()&& b.getType()== Material.SPAWNER){ 31 | if(rand.nextInt(100)<=chance){ 32 | 33 | EntityType entityType=entityTypes[rand.nextInt(entityTypes.length)]; 34 | if(EntityFeat.isAvailableEntityType(entityType)){ 35 | Location loc= event.getBlock().getLocation(); 36 | loc.getWorld().dropItemNaturally(loc, EntityFeat.getItemFromEntityType(entityType)); 37 | } 38 | 39 | } 40 | } 41 | } 42 | @EventHandler(priority = EventPriority.LOWEST,ignoreCancelled = false) 43 | public void onStopSpawnerPickaxeBreak(BlockBreakEvent event){ 44 | Block b=event.getBlock(); 45 | if(b.getType()== Material.SPAWNER){ 46 | if(DataCache.getSfItem(b.getLocation()) instanceof AbstractSpawner as){ 47 | if(CraftUtils.parseSfItem( event.getPlayer().getInventory().getItemInMainHand()) instanceof PickaxeOfContainment){ 48 | AddUtils.sendMessage(event.getPlayer(), "&c你不能使用刷怪笼之镐挖掘本附属的刷怪笼!"); 49 | event.setCancelled(true); 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/Listeners/StorageWorldListener.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.Listeners; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockPlaceEvent; 4 | import me.matl114.logitech.core.Cargo.SpaceStorage.StorageSpace; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.block.BlockBreakEvent; 8 | import org.bukkit.event.block.BlockExplodeEvent; 9 | import org.bukkit.event.block.BlockPlaceEvent; 10 | import org.bukkit.event.entity.EntityExplodeEvent; 11 | 12 | public class StorageWorldListener implements Listener { 13 | @EventHandler 14 | public void onPlace(BlockPlaceEvent event) { 15 | if(StorageSpace.ENABLED&& StorageSpace.STORAGE_WORLD==event.getBlock().getWorld()){ 16 | event.setCancelled(true); 17 | } 18 | } 19 | @EventHandler 20 | public void onBreak(BlockBreakEvent event) { 21 | if(StorageSpace.ENABLED&& StorageSpace.STORAGE_WORLD==event.getBlock().getWorld()){ 22 | event.setCancelled(true); 23 | } 24 | } 25 | @EventHandler 26 | public void onBlockExplode(BlockExplodeEvent event) { 27 | if(StorageSpace.ENABLED){ 28 | event.blockList().removeIf((block)->StorageSpace.STORAGE_WORLD==block.getWorld()); 29 | } 30 | } 31 | @EventHandler 32 | public void onEntityExplode(EntityExplodeEvent event) { 33 | if(StorageSpace.ENABLED){ 34 | event.blockList().removeIf((block)->StorageSpace.STORAGE_WORLD==block.getWorld()); 35 | } 36 | } 37 | @EventHandler 38 | public void onSfBlocPlace(SlimefunBlockPlaceEvent event){ 39 | if(StorageSpace.ENABLED&& StorageSpace.STORAGE_WORLD==event.getBlockPlaced().getWorld()){ 40 | event.setCancelled(true); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/ProtectionManager.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners; 2 | 3 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; 4 | import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionModule; 5 | import me.matl114.logitech.listeners.ProtectionModule.StorageWorldProtection; 6 | import me.matl114.logitech.manager.PostSetupTasks; 7 | import me.matl114.logitech.core.Cargo.SpaceStorage.StorageSpace; 8 | import me.matl114.logitech.utils.Debug; 9 | import org.bukkit.plugin.Plugin; 10 | import org.bukkit.plugin.PluginManager; 11 | 12 | public class ProtectionManager { 13 | public static Plugin plugin; 14 | public static PluginManager manager; 15 | public static void registerProtection(Plugin plugin,PluginManager manager) { 16 | ProtectionManager.plugin = plugin; 17 | ProtectionManager. manager = manager; 18 | if(StorageSpace.ENABLED){ 19 | register(STORAGESPACE_PROTECTION_MODULE); 20 | } 21 | } 22 | public static void register(ProtectionModule module) { 23 | PostSetupTasks.addPostRegisterTask(()->{ 24 | try { 25 | Slimefun.getProtectionManager().registerModule(manager, plugin.getName(), (pl) -> module); 26 | Debug.logger("成功注册粘液保护模块 %s".formatted(module.getName())); 27 | }catch (Throwable e) { 28 | Debug.logger("LOADING PROTECTION MODULE FAILED %s".formatted(module.getName())); 29 | e.printStackTrace(); 30 | } 31 | }); 32 | } 33 | public static ProtectionModule STORAGESPACE_PROTECTION_MODULE=new StorageWorldProtection(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/listeners/ProtectionModule/StorageWorldProtection.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.listeners.ProtectionModule; 2 | 3 | import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; 4 | import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionModule; 5 | import me.matl114.logitech.MyAddon; 6 | import me.matl114.logitech.core.Cargo.SpaceStorage.StorageSpace; 7 | import org.bukkit.Location; 8 | import org.bukkit.OfflinePlayer; 9 | import org.bukkit.plugin.Plugin; 10 | 11 | public class StorageWorldProtection implements ProtectionModule { 12 | Plugin plugin; 13 | public void load(){ 14 | //mamba out 15 | this.plugin= MyAddon.getInstance(); 16 | } 17 | 18 | public Plugin getPlugin(){ 19 | return this.plugin; 20 | } 21 | public boolean hasPermission(OfflinePlayer var1, Location var2, Interaction var3){ 22 | if(StorageSpace.ENABLED&& StorageSpace.STORAGE_WORLD==var2.getWorld()){ 23 | return false; 24 | }else { 25 | return true; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/manager/PostSetupTasks.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.manager; 2 | 3 | import me.matl114.logitech.utils.Debug; 4 | import me.matl114.logitech.core.Registries.RecipeSupporter; 5 | 6 | import java.util.HashSet; 7 | import java.util.LinkedHashSet; 8 | 9 | public class PostSetupTasks { 10 | //在服务器启动之后执行的初始化 11 | public static boolean startPostRegister=false; 12 | public static boolean recipeSupportorInit=false; 13 | public static HashSet registerTasks=new LinkedHashSet<>(); 14 | public static void addPostRegisterTask(Runnable t) { 15 | registerTasks.add(t); 16 | } 17 | public static void schedulePostRegister(){ 18 | startPostRegister=true; 19 | Debug.logger("START ADDON POSTREGISTER TASKS"); 20 | RecipeSupporter.init(); 21 | for(Runnable t : registerTasks){ 22 | t.run(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/manager/ScheduleSave.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.manager; 2 | 3 | import java.util.HashSet; 4 | 5 | public class ScheduleSave { 6 | public static HashSet FINAL_SAVES = new HashSet<>(); 7 | public static HashSet PERIODIC_SAVES = new HashSet<>(); 8 | 9 | /** 10 | * 11 | */ 12 | public static void onFinalSave(){ 13 | for (Runnable task : PERIODIC_SAVES) { 14 | task.run(); 15 | } 16 | for (Runnable task : FINAL_SAVES) { 17 | task.run(); 18 | } 19 | return; 20 | } 21 | public static void onPeriodicSave(){ 22 | for (Runnable task : PERIODIC_SAVES) { 23 | task.run(); 24 | } 25 | //Debug.logger("阶段性数据保存成功!"); 26 | return; 27 | } 28 | 29 | /** 30 | * will periodically save every 5 miniuates and when server off 31 | * @param task 32 | */ 33 | public static void addPeriodicTask(Runnable task){ 34 | PERIODIC_SAVES.add(task); 35 | } 36 | 37 | /** 38 | * will save when server off, WARNING! NO SCHEDULE LAUNCHED IN THIS PART 39 | * @param task 40 | */ 41 | public static void addFinalTask(Runnable task){ 42 | FINAL_SAVES.add(task); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/Algorithms/AtomicCounter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.Algorithms; 2 | 3 | public class AtomicCounter { 4 | private volatile int value; 5 | private final int maxinum; 6 | public AtomicCounter(int value,int max) { 7 | this.value = value; 8 | this.maxinum = max; 9 | } 10 | public boolean enough(){ 11 | return this.value >= maxinum; 12 | } 13 | public boolean empty(){ 14 | return this.value <= 0; 15 | } 16 | 17 | /** 18 | * return part that can't add into value 19 | * @param value 20 | * @return 21 | */ 22 | public int increment(int value){ 23 | int more=0; 24 | synchronized (this) { 25 | this.value+=value; 26 | more=this.value-maxinum; 27 | if(more>=0){ 28 | this.value=maxinum; 29 | } 30 | } 31 | return Math.max(more, 0); 32 | } 33 | /** 34 | * return part that can't add into value 35 | * @param value 36 | * @return 37 | */ 38 | public int safeIncrement(int value){ 39 | int expected=this.maxinum-value; 40 | synchronized (this) { 41 | if(this.value<=expected){ 42 | this.value+=value; 43 | return 0; 44 | }else{ 45 | expected-=this.value; 46 | this.value=maxinum; 47 | } 48 | } 49 | return -expected; 50 | } 51 | 52 | /** 53 | * return the required value,if not enough return as mush as it can 54 | * @param value 55 | * @return 56 | */ 57 | public int required(int value){ 58 | synchronized (this) { 59 | if(this.value>=value){ 60 | this.value-=value; 61 | return value; 62 | }else { 63 | value=this.value; 64 | this.value=0; 65 | } 66 | } 67 | return value; 68 | } 69 | 70 | public int get(){ 71 | return value; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/Algorithms/DynamicArray.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.Algorithms; 2 | 3 | import java.util.AbstractList; 4 | import java.util.List; 5 | import java.util.function.Consumer; 6 | import java.util.function.IntFunction; 7 | 8 | public class DynamicArray extends AbstractList implements List { 9 | private T[] array; 10 | private int size; 11 | private int maxinum; 12 | private IntFunction func; 13 | public DynamicArray(IntFunction generator , int size,IntFunction indexer) { 14 | this.array=generator.apply(size); 15 | this.size=size; 16 | this.func=indexer; 17 | this.maxinum=-1; 18 | } 19 | public int size(){ 20 | return size; 21 | } 22 | public boolean isEmpty(){ 23 | return size==0; 24 | } 25 | public T get(int index){ 26 | if(index<0 || index>=size){ 27 | throw new IndexOutOfBoundsException(index+" is out of bounds "+size); 28 | } 29 | T a=array[index]; 30 | this.maxinum=Math.max(maxinum,index); 31 | 32 | if(a!=null){ 33 | return a; 34 | } 35 | else { 36 | array[index]=func.apply(index); 37 | return array[index]; 38 | } 39 | } 40 | public T[] getResult(){ 41 | return array; 42 | } 43 | 44 | /** 45 | * used in array sequencial visiting 46 | * @return 47 | */ 48 | public int getMaxVisitedIndex(){ 49 | return maxinum; 50 | } 51 | public void applyPresent(Consumer action){ 52 | for(int i=0;i extends AbstractList implements List{ 7 | public W[] data; 8 | protected T[] result; 9 | protected Function mapper; 10 | protected int size; 11 | public DynamicMapper(W[] data, Function mapper,T[] result) { 12 | this.data = data; 13 | this.size = data.length; 14 | this.result = result; 15 | this.mapper=mapper; 16 | } 17 | public int size(){ 18 | return size; 19 | } 20 | public boolean isEmpty(){ 21 | return size==0; 22 | } 23 | public T get(int index){ 24 | if(index<0 || index>=size){ 25 | throw new IndexOutOfBoundsException(); 26 | }else { 27 | if(result[index]==null){ 28 | result[index]=mapper.apply(data[index]); 29 | } 30 | return result[index]; 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/Algorithms/PairList.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.Algorithms; 2 | 3 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class PairList extends ArrayList> { 8 | public void put(T key,W value){ 9 | this.add(new Pair<>(key, value)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/Algorithms/SimpleLinkList.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.Algorithms; 2 | 3 | import java.util.AbstractList; 4 | import java.util.List; 5 | 6 | public class SimpleLinkList extends AbstractList implements List { 7 | List list; 8 | int len; 9 | List data; 10 | int[] next; 11 | public SimpleLinkList(List list) { 12 | this.len =list.size() ; 13 | this.data = list; 14 | this.next = new int[len+1]; 15 | this.next[len]=-1; 16 | } 17 | public T get(int i){ 18 | return data.get(i); 19 | } 20 | public int size(){ 21 | return len; 22 | } 23 | public boolean isEmpty(){ 24 | return len == 0; 25 | } 26 | public void deleteNext(int index){ 27 | int tar=getNext(getNext(index)) ; 28 | next[index+1]=tar; 29 | } 30 | public int getNext(int index){ 31 | if(next[index+1]==0){ 32 | next[index+1]=index+1; 33 | }return next[index+1]; 34 | } 35 | public boolean hasNext(int index){ 36 | return getNext(index)>=0; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/PdcUtils.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils; 2 | 3 | import org.bukkit.NamespacedKey; 4 | import org.bukkit.persistence.PersistentDataContainer; 5 | import org.bukkit.persistence.PersistentDataType; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.Nullable; 9 | 10 | public class PdcUtils { 11 | // 12 | @Nonnull 13 | public static PersistentDataContainer getOrCreateTag(PersistentDataContainer container, NamespacedKey key) { 14 | PersistentDataContainer re=null; 15 | if(container.has(key, PersistentDataType.TAG_CONTAINER)) { 16 | re=container.get(key, PersistentDataType.TAG_CONTAINER); 17 | } 18 | if(re==null) { 19 | re=container.getAdapterContext().newPersistentDataContainer(); 20 | } 21 | return re; 22 | } 23 | @Nullable 24 | public static PersistentDataContainer getTag(PersistentDataContainer container, NamespacedKey key) { 25 | return container.get(key, PersistentDataType.TAG_CONTAINER); 26 | } 27 | public static void setTagOrRemove(PersistentDataContainer container, NamespacedKey key, PersistentDataContainer tag ) { 28 | if(tag.getKeys().isEmpty()){ 29 | container.remove(key); 30 | }else{ 31 | container.set(key,PersistentDataType.TAG_CONTAINER,tag); 32 | } 33 | 34 | } 35 | public static T getOrDefault(PersistentDataContainer container, NamespacedKey key,PersistentDataType type,T defaultValue) { 36 | if(container!=null&& container.has(key, type)) { 37 | return container.get(key, type); 38 | }else { 39 | return defaultValue; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/Settings.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils; 2 | 3 | public enum Settings { 4 | USE_SEC_EXP(), 5 | USE_TICK_EXP(), 6 | //顺序搜索 7 | SEQUNTIAL(), 8 | //逆序搜索 9 | REVERSE(), 10 | //抓取模式 消耗物品 11 | GRAB(), 12 | //推送模式 输出物品 13 | PUSH(), 14 | //初始化阶段 15 | INIT(), 16 | //运行阶段 17 | RUN(), 18 | PREFIX(), 19 | SUFFIX(), 20 | OUTPUT(), 21 | INPUT(), 22 | METHOD(), 23 | FIELD(), 24 | //for comparasion 25 | NEGATIVE(), 26 | POSITIVE(), 27 | ZERO(), 28 | NULL() 29 | ; 30 | 31 | private static int cnt=0; 32 | private static int get(){ 33 | return cnt++; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/CommandClass/AddonCommand.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.CommandClass; 2 | 3 | import me.matl114.logitech.MyAddon; 4 | import me.matl114.logitech.utils.AddUtils; 5 | import org.bukkit.command.Command; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.command.TabExecutor; 8 | import org.bukkit.entity.Player; 9 | 10 | import java.util.List; 11 | import java.util.function.Consumer; 12 | 13 | public class AddonCommand implements TabExecutor { 14 | private boolean registered = false; 15 | private final MyAddon plugin; 16 | public AddonCommand(MyAddon plugin) { 17 | this.plugin=plugin; 18 | } 19 | public boolean onCommand( CommandSender var1, Command var2, String var3, String[] var4){ 20 | if(var1 instanceof Player player){ 21 | if(var1.hasPermission("logitech.command.op")){ 22 | if(var4.length>0){ 23 | String addonName = var4[0]; 24 | boolean doExportIfAbsent=false; 25 | boolean doExportWhenEmpty=false; 26 | for (String s:var4){ 27 | if(s.startsWith("-")){ 28 | if(s.endsWith("a")){ 29 | doExportIfAbsent=true; 30 | } 31 | else if(s.endsWith("e")){ 32 | doExportWhenEmpty=true; 33 | } 34 | } 35 | } 36 | Consumer output=(str)-> AddUtils.sendMessage(player,str); 37 | ExportAddons.export(addonName,doExportIfAbsent,doExportWhenEmpty,output); 38 | }else { 39 | AddUtils.sendMessage(player,"Please enter an sf Addon to continue!"); 40 | } 41 | } 42 | } 43 | return true; 44 | } 45 | @Override 46 | public List onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) { 47 | return List.of(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/EffectClass/AbstractEffect.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.EffectClass; 2 | 3 | import me.matl114.logitech.manager.EffectTickManager; 4 | import me.matl114.logitech.utils.AddUtils; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.entity.PlayerDeathEvent; 7 | 8 | public abstract class AbstractEffect { 9 | String id; 10 | public AbstractEffect(String name) { 11 | this.id = AddUtils.idDecorator(name); 12 | } 13 | public void initEffect(Player p){ 14 | 15 | removeEffect(p,1); 16 | } 17 | 18 | public abstract void aquireEffect(Player p,int level); 19 | 20 | public abstract void removeEffect(Player p,int level); 21 | 22 | public abstract void tickEffect(Player p,int level); 23 | 24 | public String getEffectId() { 25 | return id; 26 | } 27 | public AbstractEffect reigster(){ 28 | return EffectTickManager.registerEffect(this); 29 | } 30 | 31 | public boolean onDeathClear(){ 32 | return true; 33 | } 34 | public void onDeathEvent(PlayerDeathEvent e,int level) { 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/EffectClass/PlayerEffects.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.EffectClass; 2 | 3 | import me.matl114.logitech.manager.EffectTickManager; 4 | import org.bukkit.entity.Player; 5 | 6 | import java.util.function.Function; 7 | 8 | public class PlayerEffects { 9 | public final AbstractEffect TYPE; 10 | public int duration; 11 | public int level; 12 | public boolean pendingMove; 13 | public PlayerEffects(AbstractEffect type,int time,int level) { 14 | this.TYPE = type; 15 | this.duration = time; 16 | this.level = level; 17 | this.pendingMove = false; 18 | } 19 | public final boolean isFinished(){ 20 | return duration <= 0 || this.pendingMove; 21 | } 22 | public final void finish(){ 23 | this.duration=0; 24 | } 25 | public final void halt(){ 26 | this.pendingMove=true; 27 | } 28 | public void tick(Player p){ 29 | 30 | duration--; 31 | TYPE.tickEffect(p,level); 32 | } 33 | public void end(Player p){ 34 | TYPE.removeEffect(p,level); 35 | this.pendingMove = true; 36 | } 37 | public boolean isPendingMove(){ 38 | return pendingMove; 39 | } 40 | public void start(Player p){ 41 | TYPE.aquireEffect(p,level); 42 | } 43 | public AbstractEffect getType(){ 44 | return TYPE; 45 | } 46 | public String getEffectId(){ 47 | return TYPE.getEffectId(); 48 | } 49 | public void extend(PlayerEffects eff){ 50 | 51 | this.duration=eff.duration; 52 | this.level=eff.level; 53 | } 54 | public int getLeftTime(){ 55 | return duration; 56 | } 57 | public static void grantEffect(AbstractEffect type, Player p, int level, int time, Function predicate){ 58 | PlayerEffects eff = new PlayerEffects(type,time,level); 59 | EffectTickManager.addEffect(p,eff,predicate); 60 | } 61 | public static void grantEffect(AbstractEffect type, Player p, int level, int time){ 62 | PlayerEffects eff = new PlayerEffects(type,time,level); 63 | EffectTickManager.addEffect(p,eff); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/EntityClass/TransformationBuilder.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.EntityClass; 2 | 3 | import org.bukkit.util.Transformation; 4 | import org.joml.AxisAngle4f; 5 | import org.joml.Vector3f; 6 | 7 | public final class TransformationBuilder { 8 | private AxisAngle4f firstRotation = new AxisAngle4f(0.0F, 0.0F, 1.0F, 0.0F); 9 | private AxisAngle4f secondRotation = new AxisAngle4f(0.0F, 0.0F, 1.0F, 0.0F); 10 | private Vector3f scaling = new Vector3f(1.0F, 1.0F, 1.0F); 11 | private Vector3f translation = new Vector3f(0.0F, 0.0F, 0.0F); 12 | 13 | public TransformationBuilder() { 14 | } 15 | 16 | // public TransformationBuilder firstRotation(RotationFace face, float angle) { 17 | // this.firstRotation = new AxisAngle4f((float)Math.toRadians((double)angle), face.getX(), face.getY(), face.getZ()); 18 | // return this; 19 | // } 20 | // 21 | // public TransformationBuilder secondRotation(RotationFace face, float angle) { 22 | // this.secondRotation = new AxisAngle4f((float)Math.toRadians((double)angle), face.getX(), face.getY(), face.getZ()); 23 | // return this; 24 | // } 25 | 26 | public TransformationBuilder scale(float scaleX, float scaleY, float scaleZ) { 27 | this.scaling = new Vector3f(scaleX, scaleY, scaleZ); 28 | return this; 29 | } 30 | 31 | public TransformationBuilder translation(float deltaX, float deltaY, float deltaZ) { 32 | this.translation = new Vector3f(deltaX, deltaY, deltaZ); 33 | return this; 34 | } 35 | 36 | public Transformation build() { 37 | return new Transformation(this.translation, this.firstRotation, this.scaling, this.secondRotation); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/FunctionalClass/AsyncResultRunnable.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.FunctionalClass; 2 | 3 | import me.matl114.logitech.manager.Schedules; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.scheduler.BukkitRunnable; 6 | 7 | import java.util.concurrent.CountDownLatch; 8 | 9 | public abstract class AsyncResultRunnable extends BukkitRunnable implements Runnable { 10 | public T result; 11 | public abstract T result(); 12 | public void run(){ 13 | result = result(); 14 | } 15 | public T getResult(){ 16 | return result; 17 | } 18 | public T waitThreadDone(boolean isSync){ 19 | if(Bukkit.isPrimaryThread()&&isSync){ 20 | return result(); 21 | }else { 22 | CountDownLatch latch = new CountDownLatch(1); 23 | Schedules.launchSchedules(()->{ 24 | this.run(); 25 | latch.countDown(); 26 | },0,isSync,0); 27 | try{ 28 | latch.await(); 29 | }catch(InterruptedException e) { 30 | e.printStackTrace(); 31 | } 32 | return result; 33 | 34 | } 35 | } 36 | public CountDownLatch runThreadBackground(){ 37 | CountDownLatch latch = new CountDownLatch(1); 38 | Schedules.launchSchedules(()->{ 39 | this.run(); 40 | latch.countDown(); 41 | },0,false,0); 42 | return latch; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/FunctionalClass/Counter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.FunctionalClass; 2 | 3 | public class Counter { 4 | int a; 5 | T value; 6 | public Counter() { 7 | a = 0; 8 | value = null; 9 | } 10 | public Counter(int a) { 11 | this.a = a; 12 | value = null; 13 | } 14 | public Counter(int a,T value) { 15 | this.a = a; 16 | this.value = value; 17 | } 18 | // public void increment() { 19 | // a+=1; 20 | // } 21 | // public void decrement() { 22 | // a-=1; 23 | // } 24 | // public int getCounter() { 25 | // return a; 26 | // } 27 | public void setCounter(int value) { 28 | a=value; 29 | } 30 | public T getValue() { 31 | synchronized (this){ 32 | return value; 33 | } 34 | } 35 | public void setValue(T value) { 36 | synchronized (this){ 37 | this.value = value; 38 | } 39 | } 40 | public synchronized void updateValue(T value,int counterStamp) { 41 | synchronized (this){ 42 | this.value=value; 43 | this.a=counterStamp; 44 | } 45 | } 46 | // public T read(int counterStamp){ 47 | // return read(counterStamp,1); 48 | // } 49 | public T read(int counterStamp,int delayValue){ 50 | synchronized (this){ 51 | if(this.a>=counterStamp-delayValue){ 52 | return this.value; 53 | }else { 54 | this.value=null; 55 | return null; 56 | } 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/FunctionalClass/LoreDecorator.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.FunctionalClass; 2 | 3 | import java.util.List; 4 | 5 | public interface LoreDecorator { 6 | public List decorator(List lore); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/FunctionalClass/OutputStream.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.FunctionalClass; 2 | 3 | import me.matl114.logitech.utils.AddUtils; 4 | import org.bukkit.entity.Player; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public interface OutputStream { 9 | public static OutputStream getPlayerOut(Player player) { 10 | return (OutputStream) (out)->AddUtils.sendMessage(player,out.get()); 11 | } 12 | public static OutputStream getNullStream(){ 13 | return (out)->{}; 14 | } 15 | public void out(Supplier out); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/FunctionalClass/StringDecorator.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.FunctionalClass; 2 | 3 | public interface StringDecorator { 4 | public String decorate(String s); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/AbstractItemStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public interface AbstractItemStack { 6 | //under this interface should itemstack clone to get an instance before they do sth 7 | public T copy(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/AllMatchItem.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; 4 | 5 | import me.matl114.matlib.utils.inventory.itemStacks.CleanItemStack; 6 | import org.bukkit.Material; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import java.util.List; 10 | 11 | public class AllMatchItem extends EquivalItemStack{ 12 | public static AllMatchItem ofAmount(int amount){ 13 | var re = new AllMatchItem(); 14 | re.setEqualAmount(amount); 15 | return re; 16 | } 17 | private static List> ALL_MATCH_ITEMS = List.of(new Pair<>(new CleanItemStack(Material.STONE,"&a匹配任意物品"),1)); 18 | public AllMatchItem() { 19 | super(ALL_MATCH_ITEMS); 20 | } 21 | public AllMatchItem copy(){ 22 | 23 | return ofAmount(this.getAmount()); 24 | } 25 | public boolean matchItem(ItemStack item,boolean strickCheck){ 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/ConstItemStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import me.matl114.matlib.utils.inventory.itemStacks.CleanItemStack; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.bukkit.inventory.meta.ItemMeta; 6 | 7 | public class ConstItemStack extends CleanItemStack { 8 | private ItemStack data; 9 | public ConstItemStack(ItemStack itemStack) { 10 | super(itemStack); 11 | this.data = itemStack; 12 | } 13 | public boolean setItemMeta(ItemMeta meta){ 14 | return true; 15 | } 16 | public ItemStack clone(){ 17 | return data.clone(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/ConstSlimefunItemStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 4 | import me.matl114.logitech.utils.ReflectUtils; 5 | import org.bukkit.inventory.ItemStack; 6 | import org.bukkit.inventory.meta.ItemMeta; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | public class ConstSlimefunItemStack extends SlimefunItemStack { 11 | public SlimefunItemStack data; 12 | public ItemMeta thismeta; 13 | Field lockedField; 14 | public ConstSlimefunItemStack(SlimefunItemStack stack){ 15 | super(stack.getItemId(),stack); 16 | this.data =stack ; 17 | this.thismeta = stack.getItemMeta(); 18 | this.lockedField=ReflectUtils.getDeclaredFieldsRecursively(this.getClass(),"locked").getFirstValue(); 19 | try{ 20 | Object locked=this.lockedField.get(this); 21 | this.lockedField.set(this, Boolean.FALSE); 22 | this.setItemMeta(data.getItemMeta()); 23 | this.lockedField.set(this, locked); 24 | }catch (Throwable e){ 25 | 26 | } 27 | } 28 | public ItemStack clone() { 29 | ItemStack stack= super.clone(); 30 | if(stack instanceof SlimefunItemStack){ 31 | try{ 32 | Object locked=this.lockedField.get(stack); 33 | this.lockedField.set(stack, Boolean.FALSE); 34 | stack.setItemMeta(thismeta); 35 | this.lockedField.set(stack, locked); 36 | }catch (Throwable ignored){ 37 | 38 | } 39 | } 40 | 41 | return stack; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/DisplayItemStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import me.matl114.matlib.utils.inventory.itemStacks.CleanItemStack; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | public class DisplayItemStack extends CleanItemStack implements AbstractItemStack{ 7 | public DisplayItemStack(ItemStack is){ 8 | super(is ); 9 | } 10 | public DisplayItemStack copy(){ 11 | return new DisplayItemStack(this); 12 | } 13 | 14 | 15 | public ItemStack getInstance() { 16 | return this; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/EqProRandomStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.*; 7 | 8 | public class EqProRandomStack extends RandomItemStack { 9 | public Random rand=new Random(); 10 | private List> stacks; 11 | public EqProRandomStack(List itemSettings,int ignored) { 12 | this(new ArrayList<>(){{ 13 | itemSettings.forEach(item -> { 14 | this.add(new Pair<>(item, ignored)); 15 | }); 16 | }}); 17 | 18 | } 19 | public EqProRandomStack copy(){ 20 | return new EqProRandomStack(stacks); 21 | } 22 | 23 | public EqProRandomStack(List> itemSettings) { 24 | super(itemSettings); 25 | stacks=itemSettings; 26 | } 27 | public ItemStack clone(){ 28 | return this.itemList[rand.nextInt(this.sum)].clone(); 29 | } 30 | public ItemStack getInstance(){ 31 | ItemStack it= this.itemList[rand.nextInt(this.sum)]; 32 | return (it instanceof RandOutItem w)?w.getInstance():it; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/ItemPusherProvider.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import me.matl114.logitech.utils.Settings; 4 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | import java.util.List; 8 | import java.util.function.IntFunction; 9 | import java.util.stream.IntStream; 10 | 11 | public interface ItemPusherProvider { 12 | /** 13 | * when Settings.INPUT, return ItemPusher or null if item null, 14 | * when Settings.OUTPUT return ItemPusher or ItemSlotPusher if item null 15 | 16 | * @param slot 17 | * @return 18 | */ 19 | static int[] NOSLOT= IntStream.generate(()->-1).limit(60).toArray(); 20 | ItemPusher get(Settings settings, ItemStack item, int slot); 21 | //need override? 22 | default ItemPusher getPusher(Settings settings, BlockMenu blockMenu, int slot){ 23 | return get(settings,blockMenu.getItemInSlot(slot),slot); 24 | } 25 | default IntFunction getMenu(Settings settings, BlockMenu inv, IntFunction stackFunction,int[] slots){ 26 | return (i -> get(settings,stackFunction.apply(i),slots[i])); 27 | } 28 | 29 | 30 | 31 | 32 | default IntFunction getMenuInstance(Settings settings ,BlockMenu blockMenu){ 33 | return i->get(settings,blockMenu.getItemInSlot(i),i); 34 | } 35 | default IntFunction getMenuInstance(Settings settings ,BlockMenu blockMenu,int[] slots){ 36 | return getMenu(settings,blockMenu,i->blockMenu.getItemInSlot(slots[i]),slots); 37 | } 38 | 39 | default IntFunction getMenuInstance(Settings settings ,BlockMenu blockMenu,ItemStack[] item){ 40 | return getMenu(settings,blockMenu,i->item[i],NOSLOT); 41 | } 42 | default IntFunction getMenuInstance(Settings settings , BlockMenu blockMenu, List item){ 43 | return getMenu(settings,blockMenu,(i)-> item.get(i),NOSLOT); 44 | } 45 | default IntFunction getMenuInstance(Settings settings, BlockMenu blockMenu, ItemStack[] item,int[] slots){ 46 | return getMenu(settings,blockMenu,(i)-> item[i],slots); 47 | } 48 | default IntFunction getMenuInstance(Settings settings, BlockMenu blockMenu,IntFunction prov,int[] slots){ 49 | return getMenu(settings,blockMenu,i->prov.apply(i),slots); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/ItemReplacerPusher.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | public class ItemReplacerPusher extends ItemPusher{ 7 | ItemStack source; 8 | private static ItemReplacerPusher INSTANCE=new ItemReplacerPusher(new ItemStack(Material.STONE),new ItemStack(Material.STONE)); 9 | public static ItemPusher get(ItemStack source,ItemStack data){ 10 | if(source!=null && data!=null){ 11 | return new ItemReplacerPusher(source,data); 12 | }else { 13 | return ItemPusher.get(source); 14 | } 15 | } 16 | protected ItemReplacerPusher(ItemStack replacer,ItemStack replacement){ 17 | super(replacement); 18 | this.source =replacer; 19 | 20 | } 21 | public void updateItemStack(){ 22 | super.updateItemStack(); 23 | source.setAmount(cnt); 24 | } 25 | //修复了setFrom存储时覆写maxSize的问题 26 | public void setFrom(ItemCounter source){ 27 | super.setFrom(source); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/MultiItemStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import io.github.thebusybiscuit.slimefun4.libraries.commons.lang.NotImplementedException; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.List; 7 | 8 | public interface MultiItemStack extends AbstractItemStack { 9 | public List getItemStacks(); 10 | default ItemStack clone() { 11 | throw new NotImplementedException(".clone() method not implemented"); 12 | } 13 | public int getTypeNum(); 14 | public List getWeight(Double percent); 15 | 16 | public boolean matchItem(ItemStack item,boolean strictCheck); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/ItemClass/ProbItemStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.ItemClass; 2 | 3 | import me.matl114.matlib.utils.inventory.itemStacks.CleanItemStack; 4 | import org.bukkit.Material; 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Random; 10 | 11 | public class ProbItemStack extends CleanItemStack implements MultiItemStack,RandOutItem { 12 | public Random rand=new Random(); 13 | ItemStack stack; 14 | ItemStack air=new ItemStack(Material.AIR); 15 | double prob; 16 | List stacklist; 17 | List problist; 18 | public ProbItemStack(ItemStack stack,double prob) { 19 | super(stack); 20 | this.stack = stack; 21 | this.stacklist = new ArrayList(); 22 | this.problist=new ArrayList<>(); 23 | if(stack instanceof MultiItemStack ms) { 24 | this.stacklist.addAll(ms.getItemStacks()); 25 | this.problist.addAll(ms.getWeight(prob)); 26 | }else{ 27 | this.stacklist.add(stack); 28 | this.problist.add(prob); 29 | } 30 | this.prob = prob; 31 | } 32 | public ItemStack clone(){ 33 | if(rand.nextDouble() getItemStacks() { 48 | return stacklist; 49 | } 50 | public List getWeight(Double percent){ 51 | List doubles=new ArrayList<>(); 52 | int len=this.problist.size(); 53 | for (int i=0;i handler); 15 | } 16 | public static ChestMenu.MenuClickHandler EMPTY = ChestMenuUtils.getEmptyClickHandler(); 17 | public static CustomMenuHandler empty() { 18 | return (cm -> EMPTY); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MenuClass/DataMenuClickHandler.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MenuClass; 2 | 3 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 4 | import org.bukkit.Location; 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | public interface DataMenuClickHandler extends ChestMenu.MenuClickHandler { 8 | default int getInt(int val){ 9 | return 0; 10 | } 11 | default void setInt(int val, int val2){ 12 | 13 | } 14 | default String getString(int val){ 15 | return ""; 16 | } 17 | default void setString(int val, String val2){ 18 | 19 | } 20 | default ItemStack getItemStack(int val){ 21 | return null; 22 | } 23 | default void setItemStack(int val, ItemStack val2){ 24 | 25 | } 26 | default Location getLocation(int val){ 27 | return null; 28 | } 29 | default void setLocation(int val, Location val2){ 30 | 31 | } 32 | default Object getObject(int val){ 33 | return null; 34 | } 35 | default void setObject(int val,Object val2){ 36 | 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MenuClass/DummyItemGroup.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MenuClass; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import org.bukkit.NamespacedKey; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | import javax.annotation.ParametersAreNonnullByDefault; 9 | 10 | public class DummyItemGroup extends ItemGroup { 11 | 12 | @ParametersAreNonnullByDefault 13 | public DummyItemGroup(NamespacedKey key, ItemStack item) { 14 | super(key, item); 15 | } 16 | 17 | @Override 18 | @ParametersAreNonnullByDefault 19 | public boolean isHidden(Player p) { 20 | return true; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MenuClass/GuideMenuHandler.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MenuClass; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; 4 | import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; 5 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 6 | import org.bukkit.entity.Player; 7 | 8 | public interface GuideMenuHandler { 9 | public ChestMenu.MenuClickHandler getInstance(Player var1, PlayerProfile var2, SlimefunGuideMode var3); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MenuClass/MenuPreset.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MenuClass; 2 | 3 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.HashMap; 7 | 8 | public class MenuPreset { 9 | 10 | int size; 11 | int prelen; 12 | int suflen; 13 | public MenuPreset(int size){ 14 | this(size,0,0); 15 | } 16 | public MenuPreset( int size, int prelen, int suflen) { 17 | 18 | this.size = size; 19 | this.prelen = prelen; 20 | this.suflen = suflen; 21 | } 22 | HashMap preitems=new HashMap<>(); 23 | HashMap prehandlers=new HashMap<>(); 24 | 25 | public MenuPreset addItem( ItemStack item,int... slot) { 26 | for(int slot_i :slot) 27 | preitems.put(slot_i, item); 28 | return this; 29 | } 30 | public MenuPreset addItem(ChestMenu.MenuClickHandler handler,int... slot) { 31 | for(int slot_i :slot) 32 | prehandlers.put(slot_i, handler); 33 | return this; 34 | } 35 | public MenuPreset addItem(ItemStack item, ChestMenu.MenuClickHandler handler,int... slot) { 36 | for(int slot_i :slot) 37 | prehandlers.put(slot_i, handler); 38 | return addItem(item,slot); 39 | } 40 | public HashMap getPreitems() { 41 | return preitems; 42 | } 43 | public HashMap getPrehandlers() { 44 | return prehandlers; 45 | } 46 | 47 | public int getSize() { 48 | return size; 49 | } 50 | public MenuPreset setSize(int size){ 51 | this.size = size; 52 | return this; 53 | } 54 | public int getPrelen() { 55 | return prelen; 56 | } 57 | public int getSuflen() { 58 | return suflen; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MenuClass/PlayerHistoryRecord.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MenuClass; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public interface PlayerHistoryRecord { 6 | T getRecord(Player player); 7 | void addRecord(Player player, T record); 8 | T deleteRecord(Player player,T record); 9 | void deleteAllRecords(Player player); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MenuClass/SimplePlayerHistoryRecord.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MenuClass; 2 | 3 | import me.matl114.logitech.listeners.Listeners.PlayerQuiteListener; 4 | import me.matl114.logitech.utils.Debug; 5 | import org.bukkit.entity.Player; 6 | 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.UUID; 11 | 12 | public class SimplePlayerHistoryRecord implements PlayerHistoryRecord { 13 | final HashMap> records=new HashMap<>(); 14 | { 15 | PlayerQuiteListener.addHandler((player)->{ 16 | UUID uid=player.getUniqueId(); 17 | synchronized(records) { 18 | records.remove(uid); 19 | } 20 | }); 21 | } 22 | public T getRecord(Player player){ 23 | UUID uuid=player.getUniqueId(); 24 | synchronized(records){ 25 | List list=records.get(uuid); 26 | if(list==null){ 27 | list=new ArrayList(); 28 | } 29 | if(list.isEmpty()){ 30 | return null; 31 | } 32 | return list.get(list.size()-1); 33 | } 34 | } 35 | public void addRecord(Player player, T record){ 36 | UUID uuid=player.getUniqueId(); 37 | synchronized(records){ 38 | List list = records.computeIfAbsent(uuid, k -> new ArrayList<>()); 39 | list.add(record); 40 | } 41 | } 42 | public T deleteRecord(Player player,T record){ 43 | UUID uuid=player.getUniqueId(); 44 | synchronized(records){ 45 | List list=records.get(uuid); 46 | if(list==null||list.isEmpty()){ 47 | return null; 48 | } 49 | return list.remove(list.size()-1); 50 | } 51 | } 52 | public void deleteAllRecords(Player player){ 53 | UUID uuid=player.getUniqueId(); 54 | synchronized(records){ 55 | var list = records.remove(uuid); 56 | Debug.logger(list); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MultiBlockClass/AbstractMultiBlock.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MultiBlockClass; 2 | 3 | import org.bukkit.util.Vector; 4 | 5 | public interface AbstractMultiBlock { 6 | /** 7 | * get AbstractMultiBlockType 8 | * @return 9 | */ 10 | public AbstractMultiBlockType getType(); 11 | 12 | /** 13 | * get direction 14 | * @return 15 | */ 16 | default MultiBlockService.Direction getDirection() { 17 | return MultiBlockService.Direction.NORTH; 18 | } 19 | 20 | /** 21 | * get structure size 22 | * @return 23 | */ 24 | default int getStructureSize(){ 25 | return getType().getSchemaSize(); 26 | } 27 | 28 | /** 29 | * get structure i th block, should be rotated by DIRECTION 30 | * @param index 31 | * @return 32 | */ 33 | default Vector getStructurePart(int index){ 34 | return getType().getSchemaPart(index); 35 | } 36 | 37 | /** 38 | * get structure i th id 39 | * @param index 40 | * @return 41 | */ 42 | default String getStructurePartId(int index){ 43 | 44 | return getType().getSchemaPartId(index); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MultiBlockClass/AbstractMultiBlockHandler.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MultiBlockClass; 2 | 3 | import org.bukkit.Location; 4 | 5 | public interface AbstractMultiBlockHandler { 6 | /** 7 | * location of core 8 | * @return 9 | */ 10 | public Location getCore() ; 11 | public MultiBlockService.Direction getDirection(); 12 | public AbstractMultiBlock getMultiBlock(); 13 | /** 14 | * is multiblock be build 15 | * @return 16 | */ 17 | public boolean isActive(); 18 | //响应部件信号 19 | public void toggleOff(MultiBlockService.DeleteCause cause); 20 | /** 21 | * accept in part ticks 22 | * @param loc 23 | */ 24 | public void acceptPartRequest(Location loc); 25 | //响应主核信号 返回是否还正常 26 | 27 | /** 28 | * accept in core ticks,check if active and return boolean value,when active is down, return false, 29 | * the service method will call the destroy method 30 | * @return 31 | */ 32 | public boolean acceptCoreRequest(); 33 | 34 | /** 35 | * return the size of structure 36 | * @return 37 | */ 38 | public int getSize(); 39 | 40 | /** 41 | * return the index th block in structure 42 | * @param index 43 | * @return 44 | */ 45 | public Location getBlockLoc(int index); 46 | 47 | /** 48 | * strict check if the multiblock matches,not suggested in tickers 49 | * @return 50 | */ 51 | public int checkIfComplete(); 52 | 53 | /** 54 | * random check if the multiblock matches,suggested in tickers 55 | * @return 56 | */ 57 | default int checkIfCompleteRandom(){ 58 | return checkIfComplete(); 59 | } 60 | 61 | /** 62 | * get handler uid 63 | * @return 64 | */ 65 | public String getUid(); 66 | 67 | /** 68 | * this method should called onMultiBlockDisable for CORE and reset blockdata! 69 | */ 70 | public void destroy(MultiBlockService.DeleteCause cause); 71 | 72 | public MultiBlockService.DeleteCause getLastDeleteCause(); 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MultiBlockClass/AbstractMultiBlockType.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MultiBlockClass; 2 | 3 | import me.matl114.logitech.utils.UtilClass.FunctionalClass.OutputStream; 4 | import org.bukkit.Location; 5 | import org.bukkit.util.Vector; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public interface AbstractMultiBlockType { 11 | /** 12 | * get schema block list 13 | * @return 14 | */ 15 | 16 | /** 17 | * get schema size,used in hologram type show 18 | * @return 19 | */ 20 | public int getSchemaSize(); 21 | 22 | /** 23 | * build structure map into arrays 24 | * @return 25 | */ 26 | public AbstractMultiBlockType build(); 27 | 28 | /** 29 | * add block, when x=y=z=0,ignored 30 | * @param x 31 | * @param y 32 | * @param z 33 | * @param id 34 | * @return 35 | */ 36 | //public MultiBlockType addBlock(int x, int y, int z,String id); 37 | 38 | /** 39 | * get index th block,used in hologram type show 40 | * @param index 41 | * @return 42 | */ 43 | public Vector getSchemaPart(int index); 44 | 45 | /** 46 | * get structure id list 47 | * @return 48 | */ 49 | // public BlockVector[] getStructurePos(); 50 | // 51 | // public String[] getStructureIds(); 52 | 53 | /** 54 | * get index th id,used in hologram type show 55 | * @param index 56 | * @return 57 | */ 58 | public String getSchemaPartId(int index); 59 | 60 | /** 61 | * if structure is Symmetric ,if true ,only need to check direction NORTH 62 | * @return 63 | */ 64 | public boolean isSymmetric(); 65 | 66 | /** 67 | * try generate an AbstractMultiBlock with given direction,null if failed 68 | * @param loc 69 | * @param dir 70 | * @param hasPrevRecord 71 | * @return 72 | */ 73 | public AbstractMultiBlock genMultiBlockFrom(Location loc, MultiBlockService.Direction dir, boolean hasPrevRecord, OutputStream errorStream); 74 | 75 | public List getRequiredArguments(); 76 | 77 | public Map getMultiBlockSchemaFromArguments(MultiBlockService.Direction dir,Map arguments); 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/MultiBlockClass/CubeMultiBlock/CubeMultiBlock.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.MultiBlockClass.CubeMultiBlock; 2 | 3 | import me.matl114.logitech.utils.UtilClass.MultiBlockClass.AbstractMultiBlock; 4 | import me.matl114.logitech.utils.UtilClass.MultiBlockClass.AbstractMultiBlockType; 5 | import me.matl114.logitech.utils.UtilClass.MultiBlockClass.MultiBlockService; 6 | import org.bukkit.util.Vector; 7 | 8 | public class CubeMultiBlock implements AbstractMultiBlock { 9 | private final CubeMultiBlockType TYPE; 10 | private final MultiBlockService.Direction DIRECTION; 11 | private final int height; 12 | private final int size1; 13 | private final int size2; 14 | private final int size3; 15 | public CubeMultiBlock(CubeMultiBlockType type, MultiBlockService.Direction direction,int height) { 16 | this.TYPE = type; 17 | this.DIRECTION = direction; 18 | this.height = height; 19 | this.size1=TYPE.sizeB; 20 | this.size2=size1+ TYPE.sizeP*height; 21 | this.size3=size2+TYPE.sizeT; 22 | } 23 | public AbstractMultiBlockType getType() { 24 | return TYPE; 25 | } 26 | public int getHeight() { 27 | return height; 28 | } 29 | public Vector getStructurePart(int index){ 30 | if(index multilist){ 18 | this.SUBPARTS=multilist.toArray(new AbstractMultiBlock[level]); 19 | this.schema=type; 20 | this.level=level; 21 | this.maxLevel=type.SUB_NUM; 22 | this.direction=direction; 23 | this.INDEXS=new int[level+1]; 24 | this.INDEXS[0]=0; 25 | this.SIZES=new int[level]; 26 | for (int i=0;i { 14 | public final static AbstractStorageType TYPE = new AbstractStorageType(); 15 | public static final NamespacedKey ITEM= AddUtils.getNameKey("data"); 16 | public Class getPrimitiveType(){ 17 | return PersistentDataContainer.class; 18 | } 19 | public Class getComplexType(){ 20 | return ItemStack.class; 21 | } 22 | @Override 23 | @Nonnull 24 | public PersistentDataContainer toPrimitive(@Nonnull ItemStack complex, @Nonnull PersistentDataAdapterContext context) { 25 | final PersistentDataContainer container = context.newPersistentDataContainer(); 26 | if(complex.getAmount()==1){ 27 | container.set(ITEM, DataType.ITEM_STACK, complex); 28 | } 29 | else{ 30 | complex=complex.clone(); 31 | complex.setAmount(1); 32 | container.set(ITEM, DataType.ITEM_STACK, complex); 33 | 34 | } 35 | return container; 36 | } 37 | 38 | @Override 39 | @Nonnull 40 | public ItemStack fromPrimitive(@Nonnull PersistentDataContainer primitive, @Nonnull PersistentDataAdapterContext context) { 41 | final ItemStack item = primitive.get(ITEM, DataType.ITEM_STACK); 42 | return item; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/PdcClass/AbstractStringList.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.PdcClass; 2 | 3 | 4 | import me.matl114.logitech.utils.AddUtils; 5 | import org.bukkit.NamespacedKey; 6 | import org.bukkit.persistence.PersistentDataAdapterContext; 7 | import org.bukkit.persistence.PersistentDataContainer; 8 | import org.bukkit.persistence.PersistentDataType; 9 | 10 | import javax.annotation.Nonnull; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class AbstractStringList implements PersistentDataType>{ 15 | public static final PersistentDataType> TYPE = new AbstractStringList(); 16 | 17 | public AbstractStringList() { 18 | } 19 | 20 | @Nonnull 21 | public Class getPrimitiveType() { 22 | return PersistentDataContainer.class; 23 | } 24 | private final Class clazz=(new ArrayList()).getClass(); 25 | @Nonnull 26 | public Class> getComplexType() { 27 | 28 | return (Class>)clazz; 29 | } 30 | 31 | @Nonnull 32 | public PersistentDataContainer toPrimitive(@Nonnull List complex, @Nonnull PersistentDataAdapterContext context) { 33 | PersistentDataContainer container = context.newPersistentDataContainer(); 34 | 35 | for(int i = 0; i < complex.size(); ++i) { 36 | NamespacedKey key = AddUtils.getNameKey(String.valueOf(i)) ; 37 | container.set(key, STRING, (String)complex.get(i)); 38 | } 39 | 40 | return container; 41 | } 42 | 43 | @Nonnull 44 | public List fromPrimitive(@Nonnull PersistentDataContainer primitive, @Nonnull PersistentDataAdapterContext context) { 45 | List strings = new ArrayList<>(); 46 | for(int i=0;true;++i){ 47 | NamespacedKey key = AddUtils.getNameKey(String.valueOf(i)) ; 48 | if(primitive.has(key, STRING)){ 49 | strings.add(primitive.get(key, STRING)); 50 | }else { 51 | break; 52 | } 53 | } 54 | return strings; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/RecipeClass/CustomMachineOperation.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.RecipeClass; 2 | 3 | import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; 4 | 5 | public interface CustomMachineOperation extends MachineOperation { 6 | public abstract void progress(int i); 7 | @Override 8 | default void addProgress(int i) { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/RecipeClass/EnergyProviderOperation.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.RecipeClass; 2 | 3 | import me.matl114.logitech.utils.UtilClass.ItemClass.ItemConsumer; 4 | 5 | public class EnergyProviderOperation implements CustomMachineOperation { 6 | private ItemConsumer[] outputItems; 7 | private int energyPertick; 8 | private int totalTicks; 9 | private int currentTicks; 10 | public EnergyProviderOperation(ItemConsumer[] outputItems,int time,int energyPerTick) { 11 | this.outputItems = outputItems; 12 | this.totalTicks = time; 13 | this.currentTicks = 0; 14 | this.energyPertick = energyPerTick; 15 | } 16 | public void progress(int var1){ 17 | this.currentTicks += var1; 18 | } 19 | 20 | public int getProgress(){ 21 | return this.currentTicks; 22 | } 23 | 24 | public int getTotalTicks(){ 25 | return this.totalTicks; 26 | } 27 | 28 | public int getRemainingTicks() { 29 | return this.totalTicks-this.currentTicks; 30 | } 31 | 32 | public boolean isFinished() { 33 | return this.totalTicks<=this.currentTicks; 34 | } 35 | public ItemConsumer[] getResults(){ 36 | return this.outputItems; 37 | } 38 | public int getEnergy(){ 39 | return this.energyPertick; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/RecipeClass/ImportRecipes.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.RecipeClass; 2 | 3 | public interface ImportRecipes { 4 | /** 5 | * whether the recipe will conflicts with RecipeSupport loader 6 | * if you are sure that no conflicts will occur, override this with false,and this will be read by recipesupporter 7 | * @return 8 | */ 9 | default boolean isConflict(){ 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/RecipeClass/MGeneratorRecipe.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.RecipeClass; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class MGeneratorRecipe extends StackMachineRecipe{ 6 | public MGeneratorRecipe(StackMachineRecipe r){ 7 | super(r.getTicks(),r.getInput(),r.getOutput()); 8 | } 9 | public MGeneratorRecipe(int ticks, ItemStack[] input, ItemStack[] output){ 10 | super(ticks,input,output); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/RecipeClass/MultiCraftingOperation.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.RecipeClass; 2 | 3 | import me.matl114.logitech.utils.UtilClass.ItemClass.ItemGreedyConsumer; 4 | 5 | public class MultiCraftingOperation implements CustomMachineOperation { 6 | private ItemGreedyConsumer[] outputItems; 7 | private int totalTicks; 8 | private int currentTicks; 9 | public MultiCraftingOperation(ItemGreedyConsumer[] outputItems,int time) { 10 | this.outputItems = outputItems; 11 | this.totalTicks = time; 12 | this.currentTicks = 0; 13 | for (int i = 0; i < outputItems.length; i++) { 14 | outputItems[i].clearRelated(); 15 | } 16 | } 17 | 18 | 19 | public void progress(int var1){ 20 | this.currentTicks += var1; 21 | } 22 | 23 | public int getProgress(){ 24 | return this.currentTicks; 25 | } 26 | 27 | public int getTotalTicks(){ 28 | return this.totalTicks; 29 | } 30 | 31 | public int getRemainingTicks() { 32 | return this.totalTicks-this.currentTicks; 33 | } 34 | 35 | public boolean isFinished() { 36 | return this.totalTicks<=this.currentTicks; 37 | } 38 | public ItemGreedyConsumer[] getResults(){ 39 | return this.outputItems; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/matl114/logitech/utils/UtilClass/RecipeClass/RandomMachineOperation.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech.utils.UtilClass.RecipeClass; 2 | 3 | import java.util.Random; 4 | 5 | public class RandomMachineOperation implements CustomMachineOperation { 6 | int totalTicks; 7 | long key; 8 | int currentTick; 9 | public RandomMachineOperation(int time,long key) { 10 | this.totalTicks = time; 11 | this.key = key; 12 | this.currentTick = 0; 13 | } 14 | static Random rand=new Random(); 15 | public void progress(int var1){ 16 | } 17 | public void randProgress(int amount,long value){ 18 | if(key==value){ 19 | currentTick+=amount; 20 | }else { 21 | int offset=((rand.nextInt(0,4)==0)^(key List list(T... objs) { 15 | return Arrays.stream(objs).collect(Collectors.toCollection(ArrayList::new)); 16 | } 17 | public static T[] array(T... objs) { 18 | return objs; 19 | } 20 | public static ItemStack[] toArray(List list) { 21 | return list.toArray(new ItemStack[list.size()]); 22 | 23 | } 24 | public static ItemStack[] recipe(Object ... v){ 25 | return Arrays.stream(v).map(AddUtils::resolveItem).toArray(ItemStack[]::new); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | options: 2 | auto-update: false 3 | test: false 4 | #慎用 5 | clear-old-config: false 6 | disable-spacestorage: false -------------------------------------------------------------------------------- /src/main/resources/item-settings.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1919810/LogiTech/ca3194e0ad149a37053cf72611c9d0e1412c33ce/src/main/resources/item-settings.yml -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | ## CHANGE 更改此处为你的附属名称 2 | name: LogiTech 3 | 4 | ## CHANGE 更改此处为你的名称 5 | author: matl114 6 | 7 | ## CHANGE 这是对你插件的介绍 8 | description: Logical Slimefun4-Addon To Make A Better World 9 | 10 | ## CHANGE 指向你的 JavaPlugin 主类 11 | main: me.matl114.logitech.MyAddon 12 | 13 | ## 你可以更改为你的项目仓库地址,或者你的个人网站。你也可以移除此项目。 14 | website: https://github.com/m1919810/LogiTech 15 | 16 | ## 该值将在构建时被自动替换为pom.xml中定义的版本。 17 | ## 不要更改此项目。 18 | version: ${project.version} 19 | 20 | ## 这是运行该附属所需的最低MC版本。 21 | api-version: '1.20' 22 | 23 | ## 指定 Slimefun 作为依赖项,必须 24 | 25 | depend: 26 | - Slimefun 27 | - GuizhanLibPlugin 28 | softdepend: 29 | - InfinityExpansion 30 | - Networks 31 | 32 | commands: 33 | logitech: 34 | description: basic logitech command 35 | aliases: lc 36 | usage: 'ask the author,pls.I dont think theres a need for you to use these commands' 37 | 38 | permissions: 39 | logitech.command.op: 40 | description: Allows you to use operator commands 41 | default: op 42 | logitech.shell.root: 43 | description: Allows you to open root shell without password 44 | default: op 45 | logitech.shell.test: 46 | description: Allows you to use test operator tools 47 | default: op 48 | -------------------------------------------------------------------------------- /src/main/resources/space-storage.yml: -------------------------------------------------------------------------------- 1 | index: 1 2 | storages: 3 | 0: 4 | #起始点到终点 5 | loc: 0,0,48,50,48 6 | #status 0表示未初始化过 1表示在状态1存储 2表示在状态2存储 7 | #1和2的状态需要轮流存储 8 | #1: 1~63 2:65~127 标志物: 1:0 2:64 9 | status: 1 10 | uid: 114514 -------------------------------------------------------------------------------- /src/test/java/me/matl114/logitech/TestConsumer.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech; 2 | 3 | public class TestConsumer extends TestCounter{ 4 | public TestConsumer(TestStack stack) { 5 | super(stack); 6 | } 7 | public TestConsumer clone(){ 8 | return (TestConsumer) super.clone(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/java/me/matl114/logitech/TestCounter.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | import org.junit.jupiter.api.Test; 5 | 6 | public abstract class TestCounter implements Cloneable { 7 | private TestStack it; 8 | private int amount; 9 | private boolean dirty; 10 | private final int shit=1919; 11 | public TestCounter(TestStack it) { 12 | this.it = it; 13 | this.amount = it.getAmount(); 14 | this.dirty=false; 15 | } 16 | public TestCounter clone() { 17 | TestCounter it=null; 18 | try{ 19 | it=(TestCounter)super.clone(); 20 | }catch(CloneNotSupportedException e){ 21 | e.printStackTrace(); 22 | } 23 | return it; 24 | } 25 | public boolean equals(Object o){ 26 | return false; 27 | } 28 | public void init(TestStack it){ 29 | Tests.log("TestCounter init"); 30 | this.it=it; 31 | this.amount=it.getAmount(); 32 | this.dirty=false; 33 | } 34 | } -------------------------------------------------------------------------------- /src/test/java/me/matl114/logitech/TestPusher.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech; 2 | 3 | public class TestPusher extends TestConsumer{ 4 | public int maxCnt; 5 | public TestPusher(TestStack stack){ 6 | super(stack); 7 | this.maxCnt=stack.getMaxAmount(); 8 | } 9 | public void init(TestStack stack){ 10 | super.init(stack); 11 | this.maxCnt=stack.getMaxAmount(); 12 | Tests.log("TestPusher init"); 13 | 14 | } 15 | public void init(){ 16 | // super.init(); 17 | Tests.log("TestPusher empty init"); 18 | } 19 | public TestPusher clone(){ 20 | return (TestPusher)super.clone(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/me/matl114/logitech/TestSlotPusher.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech; 2 | 3 | public class TestSlotPusher extends TestPusher{ 4 | int slot; 5 | public TestSlotPusher(TestStack stack,int slot){ 6 | super(stack); 7 | this.slot = slot; 8 | } 9 | public void init(TestStack item,int slot){ 10 | if(item!=null){ 11 | init(item); 12 | }else { 13 | super.init(); 14 | } 15 | this.slot=slot; 16 | Tests.log("TestSlotPusher init"); 17 | this.slot = slot; 18 | } 19 | public TestSlotPusher clone(){ 20 | return (TestSlotPusher) super.clone(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/me/matl114/logitech/TestStack.java: -------------------------------------------------------------------------------- 1 | package me.matl114.logitech; 2 | 3 | public class TestStack { 4 | int amount; 5 | int max; 6 | public TestStack(int amount){ 7 | this.amount = amount; 8 | this.max = 64; 9 | } 10 | public int getAmount(){ 11 | return amount; 12 | } 13 | public int getMaxAmount(){ 14 | return max; 15 | } 16 | } 17 | --------------------------------------------------------------------------------