├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature-request.md ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── github │ └── yuttyann │ └── scriptblockplus │ ├── BlockCoords.java │ ├── Scheduler.java │ ├── ScriptBlock.java │ ├── ScriptBlockAPI.java │ ├── command │ ├── BaseCommand.java │ ├── CommandUsage.java │ ├── ScriptBlockPlusCommand.java │ ├── SubCommand.java │ └── subcommand │ │ ├── BackupCommand.java │ │ ├── DatamigrCommand.java │ │ ├── ReloadCommand.java │ │ ├── ScriptCommand.java │ │ ├── SelectorCommand.java │ │ └── ToolCommand.java │ ├── enums │ ├── ActionKey.java │ ├── CommandLog.java │ ├── IndexType.java │ ├── MatchType.java │ ├── Permission.java │ ├── TeamColor.java │ └── splittype │ │ ├── Argument.java │ │ ├── Filter.java │ │ └── Repeat.java │ ├── event │ ├── BlockClickEvent.java │ ├── DelayEndEvent.java │ ├── DelayRunEvent.java │ ├── FileReloadEvent.java │ ├── RunItemEvent.java │ ├── ScriptBlockEvent.java │ ├── ScriptReadEndEvent.java │ ├── ScriptReadStartEvent.java │ └── TriggerEvent.java │ ├── file │ ├── Backup.java │ ├── Lang.java │ ├── SBFile.java │ ├── SBFiles.java │ ├── SBLoader.java │ ├── config │ │ ├── ConfigAdapter.java │ │ ├── ConfigKey.java │ │ ├── ConfigKeys.java │ │ ├── ReplaceKey.java │ │ ├── SBConfig.java │ │ └── YamlConfig.java │ └── json │ │ ├── BaseElement.java │ │ ├── BaseJson.java │ │ ├── CacheJson.java │ │ ├── GsonHolder.java │ │ ├── SubElementMap.java │ │ ├── annotation │ │ ├── Alternate.java │ │ ├── Exclude.java │ │ └── JsonTag.java │ │ ├── basic │ │ ├── OneJson.java │ │ ├── SingleJson.java │ │ ├── ThreeJson.java │ │ └── TwoJson.java │ │ ├── builder │ │ ├── BlockCoordsAdapter.java │ │ ├── CollectionType.java │ │ ├── FieldExclusion.java │ │ ├── NumberAdapter.java │ │ ├── ScriptKeyAdapter.java │ │ └── ValueHolderAdapter.java │ │ ├── derived │ │ ├── BlockScriptJson.java │ │ ├── PlayerCountJson.java │ │ ├── PlayerTimerJson.java │ │ └── element │ │ │ ├── BlockScript.java │ │ │ ├── PlayerCount.java │ │ │ ├── PlayerTimer.java │ │ │ └── ValueHolder.java │ │ └── legacy │ │ ├── ConvertList.java │ │ ├── FormatVersion.java │ │ ├── LegacyEnumFactory.java │ │ ├── LegacyFormatJson.java │ │ └── LegacyReflectiveFactory.java │ ├── hook │ ├── HookPlugin.java │ ├── nms │ │ ├── AnvilGUI.java │ │ ├── GlowEntity.java │ │ └── GlowEntityPacket.java │ └── plugin │ │ ├── DiscordSRV.java │ │ ├── Placeholder.java │ │ ├── VaultEconomy.java │ │ └── VaultPermission.java │ ├── item │ ├── ChangeSlot.java │ ├── ItemAction.java │ ├── RunItem.java │ ├── action │ │ ├── BlockSelector.java │ │ ├── ScriptEditor.java │ │ ├── ScriptManager.java │ │ ├── ScriptViewer.java │ │ └── TickRunnable.java │ └── gui │ │ ├── CustomGUI.java │ │ ├── GUIItem.java │ │ ├── UserWindow.java │ │ └── custom │ │ ├── SearchGUI.java │ │ ├── SettingGUI.java │ │ └── ToolBoxGUI.java │ ├── listener │ ├── BlockListener.java │ ├── InteractListener.java │ ├── PlayerListener.java │ ├── TriggerListener.java │ └── trigger │ │ ├── BreakTrigger.java │ │ ├── HitTrigger.java │ │ ├── InteractTrigger.java │ │ └── WalkTrigger.java │ ├── manager │ ├── APIManager.java │ ├── EndProcessManager.java │ ├── OptionManager.java │ ├── OptionMap.java │ └── SBInstance.java │ ├── player │ ├── BaseSBPlayer.java │ ├── PlayerMap.java │ ├── SBPlayer.java │ └── SBPlayerMap.java │ ├── region │ ├── CuboidRegion.java │ ├── CuboidRegionIterator.java │ ├── CuboidRegionPaste.java │ ├── CuboidRegionRemove.java │ ├── PlayerRegion.java │ └── Region.java │ ├── script │ ├── SBClipboard.java │ ├── SBOperation.java │ ├── ScriptEdit.java │ ├── ScriptKey.java │ ├── ScriptMap.java │ ├── ScriptRead.java │ ├── endprocess │ │ ├── EndInventory.java │ │ ├── EndMoneyCost.java │ │ ├── EndPlayerCount.java │ │ └── EndProcess.java │ └── option │ │ ├── BaseOption.java │ │ ├── Option.java │ │ ├── OptionIndex.java │ │ ├── OptionTag.java │ │ ├── chat │ │ ├── ActionBar.java │ │ ├── BypassOP.java │ │ ├── Command.java │ │ ├── Console.java │ │ ├── Say.java │ │ ├── Server.java │ │ ├── Title.java │ │ └── ToPlayer.java │ │ ├── discord │ │ ├── DiscordChannel.java │ │ ├── DiscordRole.java │ │ ├── DiscordRoleAdd.java │ │ └── DiscordRoleRemove.java │ │ ├── other │ │ ├── Amount.java │ │ ├── BlockType.java │ │ ├── EventInvalid.java │ │ ├── Execute.java │ │ ├── IfAction.java │ │ ├── ItemCost.java │ │ ├── ItemHand.java │ │ ├── PlaySound.java │ │ └── PlayerAction.java │ │ ├── time │ │ ├── Cooldown.java │ │ ├── Delay.java │ │ ├── OldCooldown.java │ │ └── TimerOption.java │ │ └── vault │ │ ├── BypassGroup.java │ │ ├── BypassPerm.java │ │ ├── Group.java │ │ ├── GroupAdd.java │ │ ├── GroupRemove.java │ │ ├── MoneyCost.java │ │ ├── Perm.java │ │ ├── PermAdd.java │ │ └── PermRemove.java │ ├── selector │ ├── CommandSelector.java │ ├── EntitySelector.java │ └── split │ │ ├── Split.java │ │ ├── SplitType.java │ │ └── SplitValue.java │ └── utils │ ├── ArrayUtils.java │ ├── FileUtils.java │ ├── ItemUtils.java │ ├── NMSHelper.java │ ├── StreamUtils.java │ ├── StringUtils.java │ ├── Utils.java │ ├── collection │ ├── ObjectMap.java │ └── ReuseIterator.java │ ├── kyori │ ├── KyoriGson.java │ └── KyoriLegacy.java │ ├── raytrace │ ├── RayResult.java │ ├── RayTrace.java │ └── SBBoundingBox.java │ ├── reflect │ ├── ClassType.java │ ├── Reflection.java │ ├── SimpleReflection.java │ └── matcher │ │ ├── AbstractReflectionMatcher.java │ │ ├── ConstructorMatcher.java │ │ ├── DeepConstructorMatcher.java │ │ ├── DeepFieldMatcher.java │ │ ├── DeepMethodMatcher.java │ │ ├── FieldMatcher.java │ │ ├── MethodMatcher.java │ │ └── ReflectionMatcher.java │ ├── server │ ├── CraftBukkit.java │ ├── NetMinecraft.java │ └── minecraft │ │ ├── Minecraft.java │ │ ├── NativeAccessor.java │ │ ├── PaperRemappedAccessor.java │ │ ├── SpigotAccessor_v1_14.java │ │ ├── SpigotAccessor_v1_17.java │ │ ├── SpigotAccessor_v1_20_5.java │ │ └── SpigotAccessor_v1_9.java │ ├── unmodifiable │ ├── UnmodifiableBlockCoords.java │ ├── UnmodifiableItemStack.java │ └── UnmodifiableLocation.java │ └── version │ ├── McVersion.java │ └── Version.java └── resources ├── config ├── en.yml ├── ja.yml └── zh.yml ├── message ├── en.yml ├── ja.yml └── zh.yml └── plugin.yml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: yuttyann -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report/不具合報告 3 | about: Create a report to help us improve/不具合の報告等 4 | title: '' 5 | labels: 不具合/Bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug/不具合の概要** 11 | A clear and concise description of what the bug is. 12 | 13 | **Server/サーバー** 14 | Type: (For example Spigot etc...) 15 | Version: (For example 1.16.4 etc...) 16 | Plugins: (For example ScriptBlockPlus-2.0.7 / ProtocolLib-4.5.1 etc...) 17 | 18 | **To Reproduce/再現手順** 19 | Steps to reproduce the behavior: (Texts..) 20 | 21 | **Expected behavior/期待される動作** 22 | A clear and concise description of what you expected to happen. 23 | 24 | **Screenshots/スクリーンショット** 25 | If applicable, add screenshots to help explain your problem. 26 | 27 | **Additional context/備考** 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request/機能追加・要望 3 | about: Suggest an idea for this project/機能追加・要望等 4 | title: '' 5 | labels: 機能追加・要望/Enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe./問題の説明** 11 | A clear and concise description of what the problem is. 12 | Ex. I'm always frustrated when [...] 13 | 14 | **Describe the solution you'd like/何をしたいのか** 15 | A clear and concise description of what you want to happen. 16 | 17 | **Describe alternatives you've considered/代替案** 18 | A clear and concise description of any alternative solutions or features you've considered. 19 | 20 | **Additional context/備考** 21 | Add any other context or screenshots about the feature request here. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Java 2 | *.class 3 | *.jar 4 | *.war 5 | *.ear 6 | 7 | # JavaDoc 8 | javadoc-latest 9 | 10 | # Visual Studio Code 11 | .vscode/* 12 | 13 | # Eclipse 14 | .project 15 | .classpath 16 | .settings 17 | 18 | # Idea 19 | .idea 20 | *.iml 21 | *.iws 22 | *.ipr 23 | 24 | # OS 25 | Thumbs.db 26 | .DS_Store 27 | 28 | # Gradle 29 | .gradle 30 | !gradle-wrapper.jar 31 | 32 | # Maven 33 | target 34 | 35 | # Build 36 | out 37 | build 38 | bin 39 | 40 | # Text 41 | plugin.txt 42 | header.txt 43 | 44 | # Markdown 45 | WIKI_EN.md 46 | WIKI_JP.md 47 | 48 | # Other 49 | *.log 50 | *.swp 51 | *.bak 52 | 53 | dependency-reduced-pom.xml 54 | 55 | .codegpt -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic", 3 | "java.compile.nullAnalysis.mode": "disabled" 4 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/command/CommandUsage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.command; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.Permission; 19 | import com.github.yuttyann.scriptblockplus.utils.StreamUtils; 20 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 21 | import org.bukkit.command.CommandSender; 22 | import org.jetbrains.annotations.NotNull; 23 | import org.jetbrains.annotations.Nullable; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | import java.util.Optional; 28 | 29 | /** 30 | * ScriptBlockPlus CommandUsage クラス 31 | * @author yuttyann44581 32 | */ 33 | public class CommandUsage { 34 | 35 | private final List NODES = new ArrayList<>(); 36 | 37 | private String text; 38 | 39 | public CommandUsage(@Nullable String text) { 40 | this(text, (String) null); 41 | } 42 | 43 | public CommandUsage(@Nullable String text, @Nullable String... nodes) { 44 | setText(text); 45 | addNode(nodes); 46 | } 47 | 48 | public CommandUsage(@Nullable String text, @Nullable Permission... permissions) { 49 | setText(text); 50 | StreamUtils.forEach(permissions, p -> addNode(p.getNode())); 51 | } 52 | 53 | @NotNull 54 | public String getText() { 55 | return text; 56 | } 57 | 58 | @NotNull 59 | public List getNodes() { 60 | return NODES; 61 | } 62 | 63 | public final boolean hasText() { 64 | return StringUtils.isNotEmpty(text); 65 | } 66 | 67 | public boolean hasPermission(@NotNull CommandSender sender) { 68 | if (NODES == null || NODES.size() == 0) { 69 | return true; 70 | } 71 | return NODES.stream().anyMatch(s -> Permission.has(sender, s)); 72 | } 73 | 74 | @NotNull 75 | public CommandUsage setText(@Nullable String text) { 76 | this.text = text; 77 | return this; 78 | } 79 | 80 | @NotNull 81 | public CommandUsage addNode(@Nullable String... nodes) { 82 | var value = Optional.ofNullable(nodes); 83 | if (value.isPresent() && value.get().length > 0) { 84 | StreamUtils.forEach(value.get(), NODES::add); 85 | } 86 | return this; 87 | } 88 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/command/subcommand/BackupCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.command.subcommand; 17 | 18 | import java.io.IOException; 19 | import java.nio.file.Files; 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | import org.bukkit.command.Command; 24 | import org.bukkit.command.CommandSender; 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | import com.github.yuttyann.scriptblockplus.ScriptBlock; 28 | import com.github.yuttyann.scriptblockplus.command.BaseCommand; 29 | import com.github.yuttyann.scriptblockplus.command.CommandUsage; 30 | import com.github.yuttyann.scriptblockplus.command.SubCommand; 31 | import com.github.yuttyann.scriptblockplus.enums.Permission; 32 | import com.github.yuttyann.scriptblockplus.file.Backup; 33 | import com.github.yuttyann.scriptblockplus.file.SBFile; 34 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 35 | import com.github.yuttyann.scriptblockplus.utils.FileUtils; 36 | 37 | public class BackupCommand extends SubCommand { 38 | 39 | private final Permission PERMISSION = Permission.COMMAND_BACKUP; 40 | 41 | public BackupCommand(@NotNull BaseCommand baseCommand) { 42 | super(baseCommand); 43 | } 44 | 45 | @Override 46 | @NotNull 47 | protected List getNames() { 48 | return Arrays.asList("backup"); 49 | } 50 | 51 | @Override 52 | @NotNull 53 | protected List getUsages() { 54 | return Arrays.asList(new CommandUsage(SBConfig.BACKUP_COMMAND.getValue(), PERMISSION)); 55 | } 56 | 57 | @Override 58 | protected boolean runCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label) { 59 | if (!hasPermission(sender, PERMISSION, false)) { 60 | return false; 61 | } 62 | var dataFolder = ScriptBlock.getInstance().getDataFolder(); 63 | if (!dataFolder.exists() || FileUtils.isEmpty(dataFolder)) { 64 | SBConfig.ERROR_PLUGIN_BACKUP.send(sender); 65 | return true; 66 | } 67 | try { 68 | var backup = new Backup(new SBFile(dataFolder, "backup"), path -> path.contains(SBFile.setSeparator("/backup/"))); 69 | Files.walkFileTree(backup.getFrom(), backup); 70 | SBConfig.PLUGIN_BACKUP.send(sender); 71 | } catch (IOException ex) { 72 | ex.printStackTrace(); 73 | } 74 | return true; 75 | } 76 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/command/subcommand/ReloadCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.command.subcommand; 17 | 18 | import java.util.Arrays; 19 | import java.util.List; 20 | 21 | import com.github.yuttyann.scriptblockplus.command.BaseCommand; 22 | import com.github.yuttyann.scriptblockplus.command.CommandUsage; 23 | import com.github.yuttyann.scriptblockplus.command.SubCommand; 24 | import com.github.yuttyann.scriptblockplus.enums.Permission; 25 | import com.github.yuttyann.scriptblockplus.file.SBFiles; 26 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 27 | import com.github.yuttyann.scriptblockplus.file.json.BaseJson; 28 | import com.github.yuttyann.scriptblockplus.file.json.CacheJson; 29 | import com.github.yuttyann.scriptblockplus.item.gui.CustomGUI; 30 | import com.github.yuttyann.scriptblockplus.item.gui.UserWindow; 31 | 32 | import org.bukkit.command.Command; 33 | import org.bukkit.command.CommandSender; 34 | import org.jetbrains.annotations.NotNull; 35 | 36 | /** 37 | * ScriptBlockPlus ReloadCommand コマンドクラス 38 | * @author yuttyann44581 39 | */ 40 | public class ReloadCommand extends SubCommand { 41 | 42 | private final Permission PERMISSION = Permission.COMMAND_RELOAD; 43 | 44 | public ReloadCommand(@NotNull BaseCommand baseCommand) { 45 | super(baseCommand); 46 | } 47 | 48 | @Override 49 | @NotNull 50 | protected List getNames() { 51 | return Arrays.asList("reload"); 52 | } 53 | 54 | @Override 55 | @NotNull 56 | protected List getUsages() { 57 | return Arrays.asList(new CommandUsage(SBConfig.RELOAD_COMMAND.getValue(), PERMISSION)); 58 | } 59 | 60 | @Override 61 | protected boolean runCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label) { 62 | if (!hasPermission(sender, PERMISSION, false)) { 63 | return false; 64 | } 65 | SBFiles.reload(); 66 | BaseJson.clear(); 67 | CacheJson.loading(); 68 | UserWindow.closeAll(); 69 | CustomGUI.reload(); 70 | SBConfig.ALL_FILE_RELOAD.send(sender); 71 | return true; 72 | } 73 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/command/subcommand/ToolCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.command.subcommand; 17 | 18 | import java.util.Arrays; 19 | import java.util.List; 20 | 21 | import com.github.yuttyann.scriptblockplus.command.BaseCommand; 22 | import com.github.yuttyann.scriptblockplus.command.CommandUsage; 23 | import com.github.yuttyann.scriptblockplus.command.SubCommand; 24 | import com.github.yuttyann.scriptblockplus.enums.Permission; 25 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 26 | import com.github.yuttyann.scriptblockplus.item.gui.CustomGUI; 27 | import com.github.yuttyann.scriptblockplus.item.gui.UserWindow; 28 | import com.github.yuttyann.scriptblockplus.item.gui.custom.ToolBoxGUI; 29 | 30 | import org.bukkit.command.Command; 31 | import org.bukkit.command.CommandSender; 32 | import org.bukkit.entity.Player; 33 | import org.jetbrains.annotations.NotNull; 34 | 35 | /** 36 | * ScriptBlockPlus ToolCommand コマンドクラス 37 | * @author yuttyann44581 38 | */ 39 | public class ToolCommand extends SubCommand { 40 | 41 | private final Permission PERMISSION = Permission.COMMAND_TOOL; 42 | 43 | public ToolCommand(@NotNull BaseCommand baseCommand) { 44 | super(baseCommand); 45 | } 46 | 47 | @Override 48 | @NotNull 49 | protected List getNames() { 50 | return Arrays.asList("tool"); 51 | } 52 | 53 | @Override 54 | @NotNull 55 | protected List getUsages() { 56 | return Arrays.asList(new CommandUsage(SBConfig.TOOL_COMMAND.getValue(), PERMISSION)); 57 | } 58 | 59 | @Override 60 | protected boolean runCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label) { 61 | if (!hasPermission(sender, PERMISSION)) { 62 | return false; 63 | } 64 | CustomGUI.getWindow(ToolBoxGUI.class, (Player) sender).ifPresent(UserWindow::open); 65 | return true; 66 | } 67 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/enums/ActionKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.enums; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | /** 21 | * ScriptBlockPlus ActionKey 列挙型 22 | * @author yuttyann44581 23 | */ 24 | public enum ActionKey { 25 | 26 | /** 27 | * スクリプトの作成 28 | */ 29 | CREATE("create"), 30 | 31 | /**d 32 | * スクリプトの追加 33 | */ 34 | ADD("add"), 35 | 36 | /** 37 | * スクリプトの削除 38 | */ 39 | REMOVE("remove"), 40 | 41 | /** 42 | * スクリプトの表示 43 | */ 44 | VIEW("view"), 45 | 46 | /** 47 | * スクリプトのネームタグ 48 | */ 49 | NAMETAG("nametag"), 50 | 51 | /** 52 | * セレクターの設定 53 | */ 54 | REDSTONE("redstone"); 55 | 56 | private final String name; 57 | 58 | ActionKey(@NotNull String name) { 59 | this.name = name; 60 | } 61 | 62 | @NotNull 63 | public String getName() { 64 | return name; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/enums/IndexType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.enums; 17 | 18 | /** 19 | * ScriptBlockPlus IndexType 列挙型 20 | * @author yuttyann44581 21 | */ 22 | public enum IndexType { 23 | 24 | /** 25 | * 先頭に追加 26 | */ 27 | TOP(-2), 28 | 29 | /** 30 | * 最後尾に追加 31 | */ 32 | LAST(-1), 33 | 34 | /** 35 | * 指定したオプションより一つ前に追加 36 | */ 37 | BEFORE(0), 38 | 39 | /** 40 | * 指定したオプションより一つ後に追加 41 | */ 42 | AFTER(1); 43 | 44 | private final int amount; 45 | 46 | IndexType(int amount) { 47 | this.amount = amount; 48 | } 49 | 50 | public int getAmount() { 51 | return amount; 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/enums/MatchType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.enums; 17 | 18 | /** 19 | * ScriptBlockPlus MatchType 列挙型 20 | * @author yuttyann44581 21 | */ 22 | public enum MatchType { 23 | 24 | /** 25 | * アイテムのID 26 | */ 27 | TYPE, 28 | 29 | /** 30 | * アイテムのダメージ値 31 | */ 32 | META, 33 | 34 | /** 35 | * アイテムの名前 36 | */ 37 | NAME, 38 | 39 | /** 40 | * アイテムの説明文 41 | */ 42 | LORE, 43 | 44 | /** 45 | * アイテムの個数 46 | */ 47 | AMOUNT; 48 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/enums/TeamColor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.enums; 17 | 18 | import org.bukkit.Bukkit; 19 | import org.bukkit.ChatColor; 20 | import org.bukkit.scoreboard.Scoreboard; 21 | import org.bukkit.scoreboard.Team; 22 | import org.bukkit.scoreboard.Team.Option; 23 | import org.bukkit.scoreboard.Team.OptionStatus; 24 | import org.jetbrains.annotations.NotNull; 25 | 26 | import com.github.yuttyann.scriptblockplus.utils.version.McVersion; 27 | 28 | public enum TeamColor { 29 | BLACK(ChatColor.BLACK), 30 | DARK_BLUE(ChatColor.DARK_BLUE), 31 | DARK_GREEN(ChatColor.DARK_GREEN), 32 | DARK_AQUA(ChatColor.DARK_AQUA), 33 | DARK_RED(ChatColor.DARK_RED), 34 | DARK_PURPLE(ChatColor.DARK_PURPLE), 35 | GOLD(ChatColor.GOLD), 36 | GRAY(ChatColor.GRAY), 37 | DARK_GRAY(ChatColor.DARK_GRAY), 38 | BLUE(ChatColor.BLUE), 39 | GREEN(ChatColor.GREEN), 40 | AQUA(ChatColor.AQUA), 41 | RED(ChatColor.RED), 42 | LIGHT_PURPLE(ChatColor.LIGHT_PURPLE), 43 | YELLOW(ChatColor.YELLOW), 44 | WHITE(ChatColor.WHITE); 45 | 46 | private static final String PREFIX = "SBP_"; 47 | private static final Scoreboard SCOREBOARD = Bukkit.getScoreboardManager().getMainScoreboard(); 48 | 49 | private final ChatColor chatColor; 50 | 51 | TeamColor(@NotNull ChatColor chatColor) { 52 | this.chatColor = chatColor; 53 | } 54 | 55 | @NotNull 56 | public String getName() { 57 | return PREFIX + chatColor.name(); 58 | } 59 | 60 | @NotNull 61 | public Team getTeam() { 62 | var name = getName(); 63 | var team = SCOREBOARD.getTeam(name); 64 | if (team == null) { 65 | team = SCOREBOARD.registerNewTeam(name); 66 | if (McVersion.V_1_12.isSupported()) { 67 | team.setColor(chatColor); 68 | } 69 | team.setPrefix(chatColor.toString()); 70 | team.setSuffix(chatColor.toString()); 71 | team.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); 72 | } 73 | return team; 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/enums/splittype/Argument.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.enums.splittype; 17 | 18 | import com.github.yuttyann.scriptblockplus.selector.split.SplitType; 19 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 20 | 21 | import org.jetbrains.annotations.NotNull; 22 | import org.jetbrains.annotations.Nullable; 23 | 24 | /** 25 | * ScriptBlockPlus Argument 列挙型 26 | *

27 | * Minecraft "1.12.2" までのセレクターの引数です。 28 | * @author yuttyann44581 29 | */ 30 | public enum Argument implements SplitType { 31 | X("x="), 32 | Y("y="), 33 | Z("z="), 34 | DX("dx="), 35 | DY("dy="), 36 | DZ("dz="), 37 | R("r="), 38 | RM("rm="), 39 | RX("rx="), 40 | RXM("rxm="), 41 | RY("ry="), 42 | RYM("rym="), 43 | C("c="), 44 | L("l="), 45 | LM("lm="), 46 | M("m="), 47 | TAG("tag="), 48 | TEAM("team="), 49 | TYPE("type="), 50 | NAME("name="), 51 | SCORE("score_=", "score_", "="), 52 | SCORE_MIN("score__min=", "score_", "_min="); 53 | 54 | private final String syntax, prefix, suffix; 55 | 56 | Argument(@NotNull String syntax) { 57 | this(syntax, null, null); 58 | } 59 | 60 | Argument(@NotNull String syntax, @Nullable String prefix, @Nullable String suffix) { 61 | this.syntax = syntax; 62 | this.prefix = prefix; 63 | this.suffix = suffix; 64 | } 65 | 66 | @Override 67 | @NotNull 68 | public String getValue(@NotNull String argument) { 69 | switch (this) { 70 | case SCORE: case SCORE_MIN: 71 | var objective = argument.substring(prefix.length(), argument.lastIndexOf(suffix)); 72 | return StringUtils.removeStart(argument, prefix + objective + suffix) + "*" + objective; 73 | default: 74 | return StringUtils.removeStart(argument, syntax); 75 | } 76 | } 77 | 78 | @Override 79 | public boolean match(@NotNull String argument) { 80 | switch (this) { 81 | case SCORE: 82 | return argument.startsWith(prefix) && argument.lastIndexOf(SCORE_MIN.suffix) == -1; 83 | case SCORE_MIN: 84 | return argument.startsWith(prefix) && argument.lastIndexOf(suffix) > 0; 85 | default: 86 | return argument.startsWith(syntax); 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/enums/splittype/Filter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.enums.splittype; 17 | 18 | import com.github.yuttyann.scriptblockplus.selector.split.SplitType; 19 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 20 | 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | /** 24 | * ScriptBlockPlus Filter 列挙型 25 | * @author yuttyann44581 26 | */ 27 | public enum Filter implements SplitType { 28 | 29 | /** 30 | * OPの所持、不所持を判定します。 31 | */ 32 | OP("op="), 33 | 34 | /** 35 | * 権限の所持、不所持を判定します。 36 | */ 37 | PERM("perm="), 38 | 39 | /** 40 | * 実行回数を判定します。 41 | */ 42 | LIMIT("limit="); 43 | 44 | private final String syntax; 45 | 46 | Filter(@NotNull String syntax) { 47 | this.syntax = syntax; 48 | } 49 | 50 | @NotNull 51 | public String getSyntax() { 52 | return syntax; 53 | } 54 | 55 | @NotNull 56 | public static String getPrefix() { 57 | return "filter{"; 58 | } 59 | 60 | @Override 61 | @NotNull 62 | public String getValue(@NotNull String argument) { 63 | return StringUtils.removeStart(argument, syntax); 64 | } 65 | 66 | @Override 67 | public boolean match(@NotNull String argument) { 68 | return argument.startsWith(syntax); 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/enums/splittype/Repeat.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.enums.splittype; 17 | 18 | import com.github.yuttyann.scriptblockplus.selector.split.SplitType; 19 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 20 | 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | /** 24 | * ScriptBlockPlus Repeat 列挙型 25 | * @author yuttyann44581 26 | */ 27 | public enum Repeat implements SplitType { 28 | 29 | /** 30 | * リピートの時間を設定します。 31 | */ 32 | TICK("tick="), 33 | 34 | /** 35 | * リピート開始までの時間を設定します。 36 | */ 37 | DELAY("delay="), 38 | 39 | /** 40 | * 実行回数を設定します。 41 | */ 42 | LIMIT("limit="); 43 | 44 | private final String syntax; 45 | 46 | Repeat(@NotNull String syntax) { 47 | this.syntax = syntax; 48 | } 49 | 50 | @NotNull 51 | public String getSyntax() { 52 | return syntax; 53 | } 54 | 55 | @NotNull 56 | public static String getPrefix() { 57 | return "repeat{"; 58 | } 59 | 60 | @Override 61 | @NotNull 62 | public String getValue(@NotNull String argument) { 63 | return StringUtils.removeStart(argument, syntax); 64 | } 65 | 66 | @Override 67 | public boolean match(@NotNull String argument) { 68 | return argument.startsWith(syntax); 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/event/DelayEndEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.event; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 19 | 20 | import org.bukkit.event.Event; 21 | import org.bukkit.event.HandlerList; 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | /** 25 | * ScriptBlockPlus DelayEndEvent イベントクラス 26 | * @author yuttyann44581 27 | */ 28 | public class DelayEndEvent extends Event { 29 | 30 | private static final HandlerList HANDLERS = new HandlerList(); 31 | 32 | private final ScriptRead scriptRead; 33 | 34 | /** 35 | * コンストラクタ 36 | * @param scriptRead - {@link ScriptRead}のインスタンス 37 | */ 38 | public DelayEndEvent(@NotNull ScriptRead scriptRead) { 39 | super(scriptRead.isAsynchronous()); 40 | this.scriptRead = scriptRead; 41 | } 42 | 43 | /** 44 | * {@link ScriptRead}のインスタンスを取得します。 45 | * @return {@link ScriptRead} - インスタンス 46 | */ 47 | @NotNull 48 | public ScriptRead getScriptRead() { 49 | return scriptRead; 50 | } 51 | 52 | @Override 53 | @NotNull 54 | public HandlerList getHandlers() { 55 | return HANDLERS; 56 | } 57 | 58 | @NotNull 59 | public static HandlerList getHandlerList() { 60 | return HANDLERS; 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/event/DelayRunEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.event; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 19 | 20 | import org.bukkit.event.Event; 21 | import org.bukkit.event.HandlerList; 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | /** 25 | * ScriptBlockPlus DelayRunEvent イベントクラス 26 | * @author yuttyann44581 27 | */ 28 | public class DelayRunEvent extends Event { 29 | 30 | private static final HandlerList HANDLERS = new HandlerList(); 31 | 32 | private final ScriptRead scriptRead; 33 | 34 | /** 35 | * コンストラクタ 36 | * @param scriptRead - {@link ScriptRead}のインスタンス 37 | */ 38 | public DelayRunEvent(@NotNull ScriptRead scriptRead) { 39 | super(scriptRead.isAsynchronous()); 40 | this.scriptRead = scriptRead; 41 | } 42 | 43 | /** 44 | * {@link ScriptRead}のインスタンスを取得します。 45 | * @return {@link ScriptRead} - インスタンス 46 | */ 47 | @NotNull 48 | public ScriptRead getScriptRead() { 49 | return scriptRead; 50 | } 51 | 52 | @Override 53 | @NotNull 54 | public HandlerList getHandlers() { 55 | return HANDLERS; 56 | } 57 | 58 | @NotNull 59 | public static HandlerList getHandlerList() { 60 | return HANDLERS; 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/event/FileReloadEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.event; 17 | 18 | import org.bukkit.event.Event; 19 | import org.bukkit.event.HandlerList; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | /** 23 | * ScriptBlockPlus FileReloadEvent イベントクラス 24 | * @author yuttyann44581 25 | */ 26 | public class FileReloadEvent extends Event { 27 | 28 | private static final HandlerList HANDLERS = new HandlerList(); 29 | 30 | @Override 31 | @NotNull 32 | public HandlerList getHandlers() { 33 | return HANDLERS; 34 | } 35 | 36 | @NotNull 37 | public static HandlerList getHandlerList() { 38 | return HANDLERS; 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/event/ScriptReadEndEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.event; 17 | 18 | import java.util.UUID; 19 | 20 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 21 | 22 | import org.bukkit.event.Event; 23 | import org.bukkit.event.HandlerList; 24 | import org.jetbrains.annotations.NotNull; 25 | 26 | /** 27 | * ScriptBlockPlus ScriptReadEndEvent イベントクラス 28 | * @author yuttyann44581 29 | */ 30 | public class ScriptReadEndEvent extends Event { 31 | 32 | private static final HandlerList HANDLERS = new HandlerList(); 33 | 34 | private final UUID uuid; 35 | private final com.github.yuttyann.scriptblockplus.script.option.Option.Result result; 36 | private final ScriptRead scriptRead; 37 | 38 | /** 39 | * コンストラクタ 40 | * @param uuid - スクリプトの{@link UUID} 41 | * @param scriptRead - {@link ScriptRead}のインスタンス 42 | */ 43 | public ScriptReadEndEvent(@NotNull UUID uuid, @NotNull com.github.yuttyann.scriptblockplus.script.option.Option.Result result, @NotNull ScriptRead scriptRead) { 44 | super(scriptRead.isAsynchronous()); 45 | this.uuid = uuid; 46 | this.result = result; 47 | this.scriptRead = scriptRead; 48 | } 49 | 50 | /** 51 | * スクリプトの{@link UUID}を取得します。 52 | * @return {@link UUID} - スクリプトの{@link UUID} 53 | */ 54 | @NotNull 55 | public UUID getUniqueId() { 56 | return uuid; 57 | } 58 | 59 | /** 60 | * スクリプトの実行結果を取得します。 61 | * @return {@code Result} - 成功した場合は{@code Result#SUCCESS} 62 | */ 63 | @NotNull 64 | public com.github.yuttyann.scriptblockplus.script.option.Option.Result getResult() { 65 | return result; 66 | } 67 | 68 | /** 69 | * {@link ScriptRead}のインスタンスを取得します。 70 | * @return {@link ScriptRead} - インスタンス 71 | */ 72 | @NotNull 73 | public ScriptRead getScriptRead() { 74 | return scriptRead; 75 | } 76 | 77 | @Override 78 | @NotNull 79 | public HandlerList getHandlers() { 80 | return HANDLERS; 81 | } 82 | 83 | @NotNull 84 | public static HandlerList getHandlerList() { 85 | return HANDLERS; 86 | } 87 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/event/ScriptReadStartEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.event; 17 | 18 | import java.util.UUID; 19 | 20 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 21 | 22 | import org.bukkit.event.Event; 23 | import org.bukkit.event.HandlerList; 24 | import org.jetbrains.annotations.NotNull; 25 | 26 | /** 27 | * ScriptBlockPlus ScriptReadStartEvent イベントクラス 28 | * @author yuttyann44581 29 | */ 30 | public class ScriptReadStartEvent extends Event { 31 | 32 | private static final HandlerList HANDLERS = new HandlerList(); 33 | 34 | private final UUID uuid; 35 | private final ScriptRead scriptRead; 36 | 37 | /** 38 | * コンストラクタ 39 | * @param uuid - スクリプトの{@link UUID} 40 | * @param scriptRead - {@link ScriptRead}のインスタンス 41 | */ 42 | public ScriptReadStartEvent(@NotNull UUID uuid, @NotNull ScriptRead scriptRead) { 43 | super(scriptRead.isAsynchronous()); 44 | this.uuid = uuid; 45 | this.scriptRead = scriptRead; 46 | } 47 | 48 | /** 49 | * スクリプトの{@link UUID}を取得します。 50 | * @return {@link UUID} - スクリプトの{@link UUID} 51 | */ 52 | @NotNull 53 | public UUID getUniqueId() { 54 | return uuid; 55 | } 56 | 57 | /** 58 | * {@link ScriptRead}のインスタンスを取得します。 59 | * @return {@link ScriptRead} - インスタンス 60 | */ 61 | @NotNull 62 | public ScriptRead getScriptRead() { 63 | return scriptRead; 64 | } 65 | 66 | @Override 67 | @NotNull 68 | public HandlerList getHandlers() { 69 | return HANDLERS; 70 | } 71 | 72 | @NotNull 73 | public static HandlerList getHandlerList() { 74 | return HANDLERS; 75 | } 76 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/Backup.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file; 17 | 18 | import java.io.IOException; 19 | import java.nio.file.FileVisitResult; 20 | import java.nio.file.Files; 21 | import java.nio.file.Path; 22 | import java.nio.file.SimpleFileVisitor; 23 | import java.nio.file.StandardCopyOption; 24 | import java.nio.file.attribute.BasicFileAttributes; 25 | import java.text.SimpleDateFormat; 26 | import java.util.Date; 27 | import java.util.function.Predicate; 28 | 29 | import org.jetbrains.annotations.NotNull; 30 | 31 | import com.google.common.base.Predicates; 32 | 33 | /** 34 | * Corelate-Common Backup 35 | * @author yuttyann44581 36 | */ 37 | public class Backup extends SimpleFileVisitor { 38 | 39 | public static final SimpleDateFormat SHORT_DATE_FORMAT; 40 | 41 | static { 42 | SHORT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); 43 | // SHORT_DATE_FORMAT.setTimeZone(Utils.DATE_FORMAT.getTimeZone()); 44 | } 45 | 46 | private final Path from, to; 47 | private final Predicate filter; 48 | 49 | public Backup(@NotNull SBFile backup) { 50 | this(backup, Predicates.alwaysTrue()); 51 | } 52 | 53 | public Backup(@NotNull SBFile backup, @NotNull Predicate filter) { 54 | var name = SHORT_DATE_FORMAT.format(new Date()); 55 | var size = backup.listNames((file, path) -> path.startsWith(name)).size() + 1; 56 | this.from = backup.getParentFile().toPath(); 57 | this.to = new SBFile(backup, name + '-' + size).toPath(); 58 | this.filter = filter; 59 | } 60 | 61 | @NotNull 62 | public Path getFrom() { 63 | return from; 64 | } 65 | 66 | @NotNull 67 | public Path getTo() { 68 | return to; 69 | } 70 | 71 | @Override 72 | @NotNull 73 | public FileVisitResult visitFile(@NotNull Path path, @NotNull BasicFileAttributes attributes) throws IOException { 74 | if (!filter.test(path.toString())) { 75 | var targetFile = to.resolve(from.relativize(path)); 76 | var parentDir = targetFile.getParent(); 77 | Files.createDirectories(parentDir); 78 | Files.copy(path, targetFile, StandardCopyOption.REPLACE_EXISTING); 79 | } 80 | return FileVisitResult.CONTINUE; 81 | } 82 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/Lang.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.config.YamlConfig; 19 | import com.github.yuttyann.scriptblockplus.utils.FileUtils; 20 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 21 | import org.bukkit.plugin.Plugin; 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.util.Locale; 27 | 28 | /** 29 | * ScriptBlockPlus Lang クラス 30 | * @author yuttyann44581 31 | */ 32 | public final class Lang { 33 | 34 | private static final String DEFAULT_LANGUAGE = "en"; 35 | 36 | private final Plugin plugin; 37 | private final String language; 38 | private final String filePath; 39 | private final String directory; 40 | 41 | public Lang(@NotNull Plugin plugin, @NotNull String language, @NotNull String filePath, @NotNull String directory) { 42 | this.plugin = plugin; 43 | this.language = StringUtils.isEmpty(language) ? DEFAULT_LANGUAGE : language.toLowerCase(Locale.ROOT); 44 | this.filePath = filePath; 45 | this.directory = directory; 46 | } 47 | 48 | @NotNull 49 | public String getLanguage() { 50 | return language; 51 | } 52 | 53 | @NotNull 54 | public YamlConfig load() { 55 | return YamlConfig.load(plugin, getFile(), false).setInnerPath(getPath()); 56 | } 57 | 58 | @NotNull 59 | public String getPath() { 60 | var path = directory + "/" + language + ".yml"; 61 | var code = FileUtils.getResource(plugin, path) != null ? language : DEFAULT_LANGUAGE; 62 | var file = new SBFile(plugin.getDataFolder(), StringUtils.replace(this.filePath, "{code}", code)); 63 | return !file.exists() && !code.equals(language) ? directory + "/" + code + ".yml" : path; 64 | } 65 | 66 | @NotNull 67 | public File getFile() { 68 | var path = directory + "/" + language + ".yml"; 69 | var code = FileUtils.getResource(plugin, path) != null ? language : DEFAULT_LANGUAGE; 70 | var file = new SBFile(plugin.getDataFolder(), StringUtils.replace(this.filePath, "{code}", code)); 71 | if (!file.exists()) { 72 | if (!code.equals(language)) { 73 | path = directory + "/" + code + ".yml"; 74 | } 75 | try { 76 | FileUtils.copyFileFromPlugin(plugin, file, path); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | } 81 | return file; 82 | } 83 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/SBFile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file; 17 | 18 | import java.io.File; 19 | import java.io.FilenameFilter; 20 | import java.net.URI; 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | import org.jetbrains.annotations.NotNull; 25 | 26 | /** 27 | * ScriptBlockPlus SBFile クラス 28 | *

29 | * 生成時に環境に合うセパレータに置換します。 30 | * @author yuttyann44581 31 | */ 32 | public class SBFile extends File { 33 | 34 | private static final long serialVersionUID = -303311616177581242L; 35 | 36 | public SBFile(@NotNull URI uri) { 37 | super(uri); 38 | } 39 | 40 | public SBFile(@NotNull String path) { 41 | super(setSeparator(path)); 42 | } 43 | 44 | public SBFile(@NotNull File parent, @NotNull String child) { 45 | super(parent, setSeparator(child)); 46 | } 47 | 48 | public SBFile(@NotNull String parent, @NotNull String child) { 49 | super(setSeparator(parent), setSeparator(child)); 50 | } 51 | 52 | @NotNull 53 | public static String setSeparator(@NotNull String path) { 54 | if (separatorChar != '/') { 55 | return path.replace('/', separatorChar); 56 | } 57 | return path; 58 | } 59 | 60 | @NotNull 61 | public List listNames(@NotNull FilenameFilter filter) { 62 | var names = list(); 63 | if (names == null) { 64 | return new ArrayList<>(); 65 | } 66 | var list = new ArrayList(names.length); 67 | for (int i = 0, l = names.length; i < l; i++) { 68 | var name = names[i]; 69 | if (filter.accept(this, name)) { 70 | list.add(name); 71 | } 72 | } 73 | return list; 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/SBFiles.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file; 17 | 18 | import com.github.yuttyann.scriptblockplus.ScriptBlock; 19 | import com.github.yuttyann.scriptblockplus.event.FileReloadEvent; 20 | import com.github.yuttyann.scriptblockplus.file.config.ConfigKeys; 21 | import com.github.yuttyann.scriptblockplus.file.config.YamlConfig; 22 | import org.bukkit.Bukkit; 23 | import org.bukkit.plugin.Plugin; 24 | import org.jetbrains.annotations.NotNull; 25 | 26 | import java.util.*; 27 | 28 | /** 29 | * ScriptBlockPlus SBFiles クラス 30 | * @author yuttyann44581 31 | */ 32 | public final class SBFiles { 33 | 34 | private static final Map FILES = new HashMap<>(); 35 | 36 | public static final String PATH_CONFIG = "config_{code}.yml"; 37 | public static final String PATH_MESSAGE = "message_{code}.yml"; 38 | 39 | public static void reload() { 40 | // ScriptBlockのインスタンス 41 | var plugin = ScriptBlock.getInstance(); 42 | 43 | // ファイルの内容を読み込む 44 | ConfigKeys.clear(); 45 | ConfigKeys.load(loadLang(plugin, PATH_CONFIG, "config")); 46 | ConfigKeys.load(loadLang(plugin, PATH_MESSAGE, "message")); 47 | 48 | // リロードを行ったことを知らせるイベントを呼ぶ 49 | Bukkit.getPluginManager().callEvent(new FileReloadEvent()); 50 | } 51 | 52 | @NotNull 53 | public static Map getFiles() { 54 | return Collections.unmodifiableMap(FILES); 55 | } 56 | 57 | public static Optional getFile(@NotNull Plugin plugin, @NotNull String filePath) { 58 | return Optional.ofNullable(FILES.get(plugin.getName() + "_" + filePath)); 59 | } 60 | 61 | @NotNull 62 | public static YamlConfig loadFile(@NotNull Plugin plugin, @NotNull String filePath, boolean isCopyFile) { 63 | return putFile(plugin, filePath, YamlConfig.load(plugin, filePath, isCopyFile)); 64 | } 65 | 66 | @NotNull 67 | public static YamlConfig loadLang(@NotNull Plugin plugin, @NotNull String filePath, @NotNull String directoryPath) { 68 | return putFile(plugin, filePath, new Lang(plugin, Locale.getDefault().getLanguage(), filePath, directoryPath).load()); 69 | } 70 | 71 | @NotNull 72 | private static YamlConfig putFile(@NotNull Plugin plugin, @NotNull String name, @NotNull YamlConfig yaml) { 73 | FILES.put(plugin.getName() + "_" + name, yaml); 74 | return yaml; 75 | } 76 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/config/ConfigAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.config; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * ScriptBlockPlus ConfigAdapter クラス 25 | * @author yuttyann44581 26 | */ 27 | @SuppressWarnings("unchecked") 28 | public final class ConfigAdapter { 29 | 30 | private final Map map; 31 | 32 | /** 33 | * コンストラクタ 34 | * @param map - マップ 35 | */ 36 | public ConfigAdapter(@NotNull Map map) { 37 | this.map = map; 38 | } 39 | 40 | /** 41 | * 全ての要素をクリアします。 42 | */ 43 | public void clear() { 44 | map.clear(); 45 | } 46 | 47 | /** 48 | * ファイルに含まれている全ての要素をロードします。 49 | * @param yaml - ファイル 50 | */ 51 | public void load(@NotNull YamlConfig yaml) { 52 | yaml.getKeys(true).forEach(s -> map.put(s, yaml.get(s))); 53 | } 54 | 55 | /** 56 | * 値を取得します。 57 | * @param - 値の型 58 | * @param key - キー 59 | * @return {@link T} - 値 60 | */ 61 | @Nullable 62 | public T get(@NotNull String key) { 63 | return (T) map.get(key); 64 | } 65 | 66 | /** 67 | * 値を取得します。 68 | * @param - 値の型 69 | * @param key - キー 70 | * @param def - デフォルトの値 71 | * @return {@link T} - 値 72 | */ 73 | @NotNull 74 | public T get(@NotNull String key, @NotNull T def) { 75 | T value = get(key); 76 | return value == null ? def : value; 77 | } 78 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/config/ReplaceKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.config; 17 | 18 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | import java.util.Optional; 22 | 23 | /** 24 | * ScriptBlockPlus ReplaceKey クラス 25 | * @author yuttyann44581 26 | */ 27 | public class ReplaceKey implements ConfigKey { 28 | 29 | private final ConfigKey configKey; 30 | private final String[] replaceKeys; 31 | 32 | protected Object[] args = {}; 33 | protected String result = null; 34 | 35 | /** 36 | * コンストラクタ 37 | * @param configKey - コンフィグのキー 38 | * @param replaceKeys - 検索する文字列 39 | */ 40 | public ReplaceKey(@NotNull ConfigKey configKey, @NotNull String... replaceKeys) { 41 | this.configKey = configKey; 42 | this.replaceKeys = replaceKeys; 43 | } 44 | 45 | /** 46 | * コンフィグのキーを取得します。 47 | * @return {@link ConfigKey}<{@link String}> - コンフィグのキー 48 | */ 49 | @NotNull 50 | protected final ConfigKey getConfigKey() { 51 | return configKey; 52 | } 53 | 54 | /** 55 | * 値を取得します。 56 | * @return {@link Optional}<{@link String}> - 値 57 | */ 58 | @Override 59 | @NotNull 60 | public Optional get() { 61 | return configKey.get(); 62 | } 63 | 64 | /** 65 | * 要素を取得します。 66 | * @param - 要素の型 67 | * @param index - 位置 68 | * @param classOf - 要素のクラス 69 | * @return 70 | */ 71 | @NotNull 72 | public final T getArgument(final int index, @NotNull Class classOf) { 73 | return classOf.cast(args[index]); 74 | } 75 | 76 | /** 77 | * 置換を行います。 78 | * @param replaces - 置換する要素 79 | * @return {@link ReplaceKey} - 置換後のキー 80 | */ 81 | @NotNull 82 | public ReplaceKey replace(@NotNull Object... replaces) { 83 | if (replaces.length != replaceKeys.length) { 84 | throw new IllegalArgumentException("Size are not equal."); 85 | } 86 | var replaceKey = new ReplaceKey(configKey, replaceKeys); 87 | replaceKey.args = replaces; 88 | replaceKey.result = replaceKey.configKey.getValue(); 89 | for (int i = 0; i < replaces.length; i++) { 90 | replaceKey.result = StringUtils.replace(replaceKey.result, replaceKey.replaceKeys[i], replaceKey.args[i]); 91 | } 92 | return replaceKey; 93 | } 94 | 95 | @Override 96 | public String toString() { 97 | return result == null ? configKey.toString() : result; 98 | } 99 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/BaseElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json; 17 | 18 | import java.util.Objects; 19 | 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | /** 23 | * ScriptBlockPlus BaseElement クラス 24 | * @author yuttyann44581 25 | */ 26 | public abstract class BaseElement implements Cloneable { 27 | 28 | /** 29 | * 引数同士を比較します。 30 | * @param argument1 - 引数1 31 | * @param argument2 - 引数2 32 | * @return {@code boolean} - 引数が一致するのかどうか 33 | */ 34 | protected boolean compare(@NotNull Object argument1, @NotNull Object argument2) { 35 | return Objects.equals(argument1, argument2); 36 | } 37 | 38 | /** 39 | * エレメントのクラスを取得します。 40 | * @return {@link Class}<? extends {@link BaseElement}> - エレメントのクラス 41 | */ 42 | @NotNull 43 | public Class getElementType() { 44 | return BaseElement.class; 45 | } 46 | 47 | @Override 48 | public BaseElement clone() throws CloneNotSupportedException { 49 | return (BaseElement) super.clone(); 50 | } 51 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/annotation/Alternate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.annotation; 17 | 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.Target; 20 | 21 | import com.google.gson.annotations.SerializedName; 22 | 23 | import static java.lang.annotation.ElementType.FIELD; 24 | import static java.lang.annotation.ElementType.METHOD; 25 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 26 | 27 | /** 28 | * ScriptBlockPlus Alternate 注釈 29 | *

30 | * Gsonのバージョンが古い場合に呼び出されます。 31 | *

32 | * {@link SerializedName#alternate()}と同等の機能を持っています。 33 | * @author yuttyann44581 34 | */ 35 | @Target({ FIELD, METHOD }) 36 | @Retention(RUNTIME) 37 | public @interface Alternate { 38 | 39 | /** 40 | * デシリアライズした時の代替名を取得します。 41 | * @return {@link String} - 代替名 42 | */ 43 | String[] value() default {}; 44 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/annotation/Exclude.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.annotation; 17 | 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.Target; 20 | 21 | import static java.lang.annotation.ElementType.FIELD; 22 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 23 | 24 | /** 25 | * ScriptBlockPlus Exclude 注釈 26 | *

27 | * この注釈を付与することで、デシリアライズをスルーすることが出来ます。 28 | * @author yuttyann44581 29 | */ 30 | @Target(FIELD) 31 | @Retention(RUNTIME) 32 | public @interface Exclude { 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/annotation/JsonTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.annotation; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.Target; 22 | 23 | import static java.lang.annotation.ElementType.TYPE; 24 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 25 | 26 | /** 27 | * ScriptBlockPlus JsonTag 注釈 28 | * @author yuttyann44581 29 | */ 30 | @Target(TYPE) 31 | @Retention(RUNTIME) 32 | public @interface JsonTag { 33 | 34 | /** 35 | * ディレクトリのパスを取得します。 36 | *

37 | * 例(json/testフォルダを指定する場合): {@code json/test} 38 | * @return {@link String} - ディレクトリのパス 39 | */ 40 | @NotNull 41 | String path(); 42 | 43 | /** 44 | * プラグインのIDを取得します。 45 | *

46 | * 指定したプラグインのフォルダ内にファイルを生成します。 47 | *

48 | * 指定しない場合は"ScriptBlockPlus"が選択されます。 49 | * @return {@link String} - プラグインのID 50 | */ 51 | @NotNull 52 | String plugin() default ""; 53 | 54 | /** 55 | * インデントを取得します。 56 | *

57 | * 整形を行う際に利用されます。 58 | * @return {@link String} - インデント 59 | */ 60 | @NotNull 61 | String indent() default " "; 62 | 63 | /** 64 | * ファイルを保存した時にキャッシュを削除するのかどうか。 65 | * @return {@link boolean} - 削除を行う場合は{@code true} 66 | */ 67 | boolean temporary() default false; 68 | 69 | /** 70 | * ファイルが存在する時のみキャッシュを保存するのかどうか。 71 | * @return {@link boolean} - ファイルが存在する時のみキャッシュを保存する場合は{@code true} 72 | */ 73 | boolean cachefileexists() default false; 74 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/builder/BlockCoordsAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.builder; 17 | 18 | import java.lang.reflect.Type; 19 | 20 | import com.github.yuttyann.scriptblockplus.BlockCoords; 21 | import com.google.gson.JsonDeserializationContext; 22 | import com.google.gson.JsonDeserializer; 23 | import com.google.gson.JsonElement; 24 | import com.google.gson.JsonParseException; 25 | import com.google.gson.JsonSerializationContext; 26 | import com.google.gson.JsonSerializer; 27 | 28 | import org.jetbrains.annotations.NotNull; 29 | 30 | /** 31 | * ScriptBlockPlus BlockCoordsAdapter クラス 32 | * @author yuttyann44581 33 | */ 34 | public final class BlockCoordsAdapter implements JsonSerializer, JsonDeserializer { 35 | 36 | @Override 37 | @NotNull 38 | public JsonElement serialize(@NotNull BlockCoords blockCoords, @NotNull Type typeOfSrc, @NotNull JsonSerializationContext context) { 39 | return context.serialize(blockCoords.getFullCoords()); 40 | } 41 | 42 | @Override 43 | @NotNull 44 | public BlockCoords deserialize(@NotNull JsonElement json, @NotNull Type typeOfT, @NotNull JsonDeserializationContext context) throws JsonParseException { 45 | return BlockCoords.fromString(json.getAsString()); 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/builder/CollectionType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.builder; 17 | 18 | import java.lang.reflect.ParameterizedType; 19 | import java.lang.reflect.Type; 20 | import java.util.Collection; 21 | 22 | import com.github.yuttyann.scriptblockplus.file.json.BaseJson; 23 | 24 | import org.jetbrains.annotations.NotNull; 25 | import org.jetbrains.annotations.Nullable; 26 | 27 | /** 28 | * ScriptBlockPlus CollectionType クラス 29 | * @author yuttyann44581 30 | */ 31 | @SuppressWarnings("rawtypes") 32 | public final class CollectionType implements ParameterizedType { 33 | 34 | private final Type[] types; 35 | private final Class rawType; 36 | 37 | public CollectionType(@NotNull Class rawType, @NotNull BaseJson json) throws ClassNotFoundException { 38 | var type = json.getClass().getGenericSuperclass(); 39 | var args = ((ParameterizedType) type).getActualTypeArguments(); 40 | this.types = new Type[] { Class.forName(args[args.length - 1].getTypeName()) }; 41 | this.rawType = rawType; 42 | } 43 | 44 | @Override 45 | @NotNull 46 | public Type[] getActualTypeArguments() { 47 | return types; 48 | } 49 | 50 | @Override 51 | @NotNull 52 | public Type getRawType() { 53 | return rawType; 54 | } 55 | 56 | @Override 57 | @Nullable 58 | public Type getOwnerType() { 59 | return null; 60 | } 61 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/builder/FieldExclusion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.builder; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.json.annotation.Exclude; 19 | import com.google.gson.ExclusionStrategy; 20 | import com.google.gson.FieldAttributes; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | /** 24 | * ScriptBlockPlus FieldExclusion クラス 25 | * @author yuttyann44581 26 | */ 27 | public final class FieldExclusion implements ExclusionStrategy { 28 | 29 | @Override 30 | public boolean shouldSkipField(@NotNull FieldAttributes field) { 31 | return field.getAnnotation(Exclude.class) != null; 32 | } 33 | 34 | @Override 35 | public boolean shouldSkipClass(@NotNull Class clazz) { 36 | return false; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/builder/NumberAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.builder; 17 | 18 | import java.io.IOException; 19 | import java.util.ArrayList; 20 | 21 | import com.github.yuttyann.scriptblockplus.file.json.BaseJson; 22 | import com.google.gson.TypeAdapter; 23 | import com.google.gson.internal.LinkedTreeMap; 24 | import com.google.gson.stream.JsonReader; 25 | import com.google.gson.stream.JsonWriter; 26 | 27 | import org.jetbrains.annotations.NotNull; 28 | import org.jetbrains.annotations.Nullable; 29 | 30 | /** 31 | * ScriptBlockPlus NumberAdapter クラス 32 | * @author yuttyann44581 33 | */ 34 | public final class NumberAdapter extends TypeAdapter { 35 | 36 | private final TypeAdapter DELEGATE = BaseJson.GSON_HOLDER.getGson().getAdapter(Object.class); 37 | 38 | @Override 39 | public void write(@NotNull JsonWriter out, @Nullable Object value) throws IOException { 40 | DELEGATE.write(out, value); 41 | } 42 | 43 | @Override 44 | @Nullable 45 | public Object read(@NotNull JsonReader reader) throws IOException { 46 | var jsonToken = reader.peek(); 47 | switch (jsonToken) { 48 | case BEGIN_ARRAY: { 49 | var list = new ArrayList(); 50 | reader.beginArray(); 51 | while (reader.hasNext()) { 52 | list.add(read(reader)); 53 | } 54 | reader.endArray(); 55 | return list; 56 | } 57 | case BEGIN_OBJECT: { 58 | var map = new LinkedTreeMap(); 59 | reader.beginObject(); 60 | while (reader.hasNext()) { 61 | map.put(reader.nextName(), read(reader)); 62 | } 63 | reader.endObject(); 64 | return map; 65 | } 66 | case STRING: { 67 | return reader.nextString(); 68 | } 69 | case NUMBER: { 70 | var next = reader.nextString(); 71 | if (next.indexOf('.') != -1) { 72 | return Double.parseDouble(next); 73 | } 74 | return Long.parseLong(next); 75 | } 76 | case BOOLEAN: { 77 | return reader.nextBoolean(); 78 | } 79 | case NULL: { 80 | reader.nextNull(); 81 | return null; 82 | } 83 | default: 84 | throw new IllegalStateException(); 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/builder/ScriptKeyAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.builder; 17 | 18 | import java.lang.reflect.Type; 19 | 20 | import com.github.yuttyann.scriptblockplus.script.ScriptKey; 21 | import com.google.gson.JsonDeserializationContext; 22 | import com.google.gson.JsonDeserializer; 23 | import com.google.gson.JsonElement; 24 | import com.google.gson.JsonParseException; 25 | import com.google.gson.JsonSerializationContext; 26 | import com.google.gson.JsonSerializer; 27 | 28 | import org.jetbrains.annotations.NotNull; 29 | 30 | /** 31 | * ScriptBlockPlus ScriptKeyAdapter クラス 32 | * @author yuttyann44581 33 | */ 34 | public final class ScriptKeyAdapter implements JsonSerializer, JsonDeserializer { 35 | 36 | @Override 37 | @NotNull 38 | public JsonElement serialize(@NotNull ScriptKey scriptKey, @NotNull Type typeOfSrc, @NotNull JsonSerializationContext context) { 39 | return context.serialize(scriptKey.toString()); 40 | } 41 | 42 | @Override 43 | @NotNull 44 | public ScriptKey deserialize(@NotNull JsonElement json, @NotNull Type typeOfT, @NotNull JsonDeserializationContext context) throws JsonParseException { 45 | if (json.isJsonObject()) { 46 | var jsonObject = json.getAsJsonObject(); 47 | if (!jsonObject.has("name")) { 48 | return ScriptKey.INTERACT; 49 | } 50 | return ScriptKey.valueOf(jsonObject.get("name").getAsString()); 51 | } 52 | return ScriptKey.get(json.getAsString()); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/builder/ValueHolderAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.builder; 17 | 18 | import java.lang.reflect.Type; 19 | 20 | import com.github.yuttyann.scriptblockplus.file.json.derived.element.ValueHolder; 21 | import com.github.yuttyann.scriptblockplus.file.json.derived.element.ValueHolder.ValueType; 22 | import com.google.gson.JsonDeserializationContext; 23 | import com.google.gson.JsonDeserializer; 24 | import com.google.gson.JsonElement; 25 | import com.google.gson.JsonParseException; 26 | import com.google.gson.JsonSerializationContext; 27 | import com.google.gson.JsonSerializer; 28 | 29 | import org.jetbrains.annotations.NotNull; 30 | 31 | /** 32 | * ScriptBlockPlus ValueHolderAdapter クラス 33 | * @author yuttyann44581 34 | */ 35 | public final class ValueHolderAdapter implements JsonSerializer, JsonDeserializer { 36 | 37 | @Override 38 | @NotNull 39 | public JsonElement serialize(@NotNull ValueHolder valueHolder, @NotNull Type typeOfSrc, @NotNull JsonSerializationContext context) { 40 | return context.serialize(valueHolder.toString()); 41 | } 42 | 43 | @Override 44 | @NotNull 45 | public ValueHolder deserialize(@NotNull JsonElement json, @NotNull Type typeOfT, @NotNull JsonDeserializationContext context) throws JsonParseException { 46 | var text = json.getAsString(); 47 | var index = text.indexOf(':'); 48 | var valueType = ValueType.valueOf(text.substring(0, index).toUpperCase()); 49 | return new ValueHolder(valueType, valueType.parse(text.substring(index + 1, text.length()))); 50 | } 51 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/file/json/legacy/FormatVersion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.file.json.legacy; 17 | 18 | import java.io.Serializable; 19 | 20 | import org.jetbrains.annotations.Nullable; 21 | 22 | /** 23 | * ScriptBlockPlus FormatVersion クラス 24 | * @author yuttyann44581 25 | */ 26 | public final class FormatVersion implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | public static final FormatVersion ZERO = new FormatVersion(0.0); 31 | public static final FormatVersion CURRENT = new FormatVersion(3.0); 32 | 33 | private final double version; 34 | 35 | /** 36 | * コンストラクタ 37 | */ 38 | public FormatVersion() { 39 | this(CURRENT.getVersion()); 40 | } 41 | 42 | /** 43 | * コンストラクタ 44 | * @param version - バージョン 45 | */ 46 | private FormatVersion(final double version) { 47 | this.version = version; 48 | } 49 | 50 | /** 51 | * バージョンを取得します。 52 | * @return {@code double} - バージョン 53 | */ 54 | public double getVersion() { 55 | return version; 56 | } 57 | 58 | @Override 59 | public boolean equals(@Nullable Object obj) { 60 | if (obj == this) { 61 | return true; 62 | } 63 | return obj instanceof FormatVersion ? this.version == ((FormatVersion) obj).getVersion() : false; 64 | } 65 | 66 | @Override 67 | public int hashCode() { 68 | return Double.hashCode(version); 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/hook/HookPlugin.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.hook; 17 | 18 | import org.bukkit.Bukkit; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | /** 22 | * ScriptBlockPlus HookPlugin クラス 23 | * @author yuttyann44581 24 | */ 25 | public abstract class HookPlugin { 26 | 27 | /** 28 | * プラグイン名を取得します。 29 | * @return プラグイン名 30 | */ 31 | @NotNull 32 | public abstract String getPluginName(); 33 | 34 | /** 35 | * プラグインが有効なのか確認します。 36 | * @return プラグインが有効な場合は{@code true} 37 | */ 38 | public final boolean has() { 39 | return Bukkit.getPluginManager().isPluginEnabled(getPluginName()); 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/item/ChangeSlot.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.item; 17 | 18 | import com.github.yuttyann.scriptblockplus.player.SBPlayer; 19 | import org.bukkit.Material; 20 | import org.bukkit.entity.Player; 21 | import org.bukkit.inventory.ItemStack; 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | import java.util.Optional; 25 | 26 | /** 27 | * ScriptBlockPlus ChangeSlot クラス 28 | * @author yuttyann44581 29 | */ 30 | public final class ChangeSlot { 31 | 32 | private final SBPlayer sbPlayer; 33 | private final int newSlot, oldSlot; 34 | 35 | /** 36 | * コンストラクタ 37 | * @param sbPlayer - プレイヤー 38 | * @param newSlot - 移動先のスロット 39 | * @param oldSlot - 移動前のスロット 40 | */ 41 | public ChangeSlot(@NotNull SBPlayer sbPlayer, int newSlot, int oldSlot) { 42 | this.sbPlayer = sbPlayer; 43 | this.newSlot = newSlot; 44 | this.oldSlot = oldSlot; 45 | } 46 | 47 | /** 48 | * {@code BukkitAPI}の{@code org.bukkit.entity.Player}を取得します。 49 | * @return {@link Player} - プレイヤー 50 | */ 51 | @Deprecated 52 | @NotNull 53 | public Player getPlayer() { 54 | return sbPlayer.toPlayer(); 55 | } 56 | 57 | /** 58 | * プレイヤーを取得します。 59 | * @return {@link SBPlayer} - プレイヤー 60 | */ 61 | @NotNull 62 | public SBPlayer getSBPlayer() { 63 | return sbPlayer; 64 | } 65 | 66 | @NotNull 67 | public ItemStack getNewItem() { 68 | return Optional.ofNullable(sbPlayer.getInventory().getItem(newSlot)).orElse(new ItemStack(Material.AIR)); 69 | } 70 | 71 | @NotNull 72 | public ItemStack getOldItem() { 73 | return Optional.ofNullable(sbPlayer.getInventory().getItem(oldSlot)).orElse(new ItemStack(Material.AIR)); 74 | } 75 | 76 | public int getNewSlot() { 77 | return newSlot; 78 | } 79 | 80 | public int getOldSlot() { 81 | return oldSlot; 82 | } 83 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/item/RunItem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.item; 17 | 18 | import com.github.yuttyann.scriptblockplus.BlockCoords; 19 | import com.github.yuttyann.scriptblockplus.player.SBPlayer; 20 | 21 | import org.bukkit.event.block.Action; 22 | import org.bukkit.inventory.ItemStack; 23 | import org.jetbrains.annotations.NotNull; 24 | import org.jetbrains.annotations.Nullable; 25 | 26 | /** 27 | * ScriptBlockPlus RunItem クラス 28 | * @author yuttyann44581 29 | */ 30 | public final class RunItem { 31 | 32 | private final ItemStack item; 33 | private final SBPlayer sbPlayer; 34 | private final Action action; 35 | private final BlockCoords blockCoords; 36 | 37 | /** 38 | * コンストラクタ 39 | * @param item - アイテム 40 | * @param sbPlayer - プレイヤー 41 | * @param action - アクション 42 | * @param blockCoords - 座標 43 | */ 44 | public RunItem(@NotNull ItemStack item, @NotNull SBPlayer sbPlayer, @NotNull Action action, @Nullable BlockCoords blockCoords) { 45 | this.item = item; 46 | this.sbPlayer = sbPlayer; 47 | this.action = action; 48 | this.blockCoords = blockCoords; 49 | } 50 | 51 | /** 52 | * アイテムを取得します。 53 | * @return {@link ItemStack} - アイテム 54 | */ 55 | @NotNull 56 | public ItemStack getItem() { 57 | return item; 58 | } 59 | 60 | /** 61 | * プレイヤーを取得します。 62 | * @return {@link SBPlayer} - プレイヤー 63 | */ 64 | @NotNull 65 | public SBPlayer getSBPlayer() { 66 | return sbPlayer; 67 | } 68 | 69 | /** 70 | * アクションを取得します。 71 | * @return {@link Action} - アクション 72 | */ 73 | @NotNull 74 | public Action getAction() { 75 | return action; 76 | } 77 | 78 | /** 79 | * 座標を取得します。 80 | * @return {@link BlockCoords} - 座標 81 | */ 82 | @Nullable 83 | public BlockCoords getBlockCoords() { 84 | return blockCoords; 85 | } 86 | 87 | /** 88 | * 空気関連のアクションの場合は{@code true}を返します。 89 | * @return {@code boolean} - 空気関連のアクションの場合は{@code true} 90 | */ 91 | public boolean isAIR() { 92 | return action.name().endsWith("_CLICK_AIR"); 93 | } 94 | 95 | /** 96 | * プレイヤーがスニーク状態の場合は{@code true}を返します。 97 | * @return {@code boolean} - プレイヤーがスニーク状態の場合は{@code true} 98 | */ 99 | public boolean isSneaking() { 100 | return sbPlayer.toPlayer().isSneaking(); 101 | } 102 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/item/action/BlockSelector.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.item.action; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.Permission; 19 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 20 | import com.github.yuttyann.scriptblockplus.item.ItemAction; 21 | import com.github.yuttyann.scriptblockplus.item.RunItem; 22 | 23 | import org.bukkit.Material; 24 | import org.bukkit.inventory.ItemFlag; 25 | import org.bukkit.permissions.Permissible; 26 | import org.jetbrains.annotations.NotNull; 27 | 28 | import static com.github.yuttyann.scriptblockplus.BlockCoords.*; 29 | 30 | /** 31 | * ScriptBlockPlus BlockSelector クラス 32 | * @author yuttyann44581 33 | */ 34 | public final class BlockSelector extends ItemAction { 35 | 36 | public BlockSelector() { 37 | super(Material.STICK, () -> "§dBlock Selector", SBConfig.BLOCK_SELECTOR::setListColor); 38 | setItemFlags(ItemFlag.HIDE_ATTRIBUTES); 39 | } 40 | 41 | @Override 42 | public void run(@NotNull RunItem runItem) { 43 | var sbPlayer = runItem.getSBPlayer(); 44 | var blockCoords = runItem.isSneaking() ? of(sbPlayer.getLocation()) : runItem.isAIR() ? null : copy(runItem.getBlockCoords()); 45 | if (blockCoords == null) { 46 | return; 47 | } 48 | var region = sbPlayer.getCuboidRegion(); 49 | switch (runItem.getAction()) { 50 | case LEFT_CLICK_AIR: case LEFT_CLICK_BLOCK: 51 | region.setPosition1(blockCoords); 52 | SBConfig.SELECTOR_POS1.replace(region.getName(), blockCoords.getCoords()).send(sbPlayer); 53 | break; 54 | case RIGHT_CLICK_AIR: case RIGHT_CLICK_BLOCK: 55 | region.setPosition2(blockCoords); 56 | SBConfig.SELECTOR_POS2.replace(region.getName(), blockCoords.getCoords()).send(sbPlayer); 57 | break; 58 | default: 59 | } 60 | } 61 | 62 | @Override 63 | public boolean hasPermission(@NotNull Permissible permissible) { 64 | return Permission.TOOL_BLOCK_SELECTOR.has(permissible); 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/item/action/ScriptManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.item.action; 17 | 18 | import org.bukkit.Material; 19 | import org.bukkit.inventory.ItemFlag; 20 | import org.bukkit.permissions.Permissible; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | import com.github.yuttyann.scriptblockplus.enums.Permission; 24 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 25 | import com.github.yuttyann.scriptblockplus.item.ItemAction; 26 | import com.github.yuttyann.scriptblockplus.item.RunItem; 27 | import com.github.yuttyann.scriptblockplus.item.gui.CustomGUI; 28 | import com.github.yuttyann.scriptblockplus.item.gui.UserWindow; 29 | import com.github.yuttyann.scriptblockplus.item.gui.custom.SearchGUI; 30 | import com.github.yuttyann.scriptblockplus.utils.server.NetMinecraft; 31 | 32 | /** 33 | * ScriptBlockPlus ScriptManager クラス 34 | * @author yuttyann44581 35 | */ 36 | public class ScriptManager extends ItemAction { 37 | 38 | public ScriptManager() { 39 | super(Material.BOOK, () -> "§dScript Manager", SBConfig.SCRIPT_MANAGER::setListColor); 40 | setItemFlags(ItemFlag.HIDE_ATTRIBUTES); 41 | } 42 | 43 | @Override 44 | public void run(@NotNull RunItem runItem) { 45 | switch (runItem.getAction()) { 46 | case RIGHT_CLICK_AIR: case RIGHT_CLICK_BLOCK: 47 | if (!NetMinecraft.hasNMS()) { 48 | runItem.getSBPlayer().sendMessage("§c" + NetMinecraft.WARNING_TEXT); 49 | return; 50 | } 51 | CustomGUI.getWindow(SearchGUI.class, runItem.getSBPlayer()).ifPresent(UserWindow::open); 52 | break; 53 | default: 54 | break; 55 | } 56 | } 57 | 58 | @Override 59 | public boolean hasPermission(@NotNull Permissible permissible) { 60 | return Permission.TOOL_SCRIPT_MANAGER.has(permissible); 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/item/action/ScriptViewer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.item.action; 17 | 18 | import com.github.yuttyann.scriptblockplus.ScriptBlock; 19 | import com.github.yuttyann.scriptblockplus.enums.Permission; 20 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 21 | import com.github.yuttyann.scriptblockplus.item.ChangeSlot; 22 | import com.github.yuttyann.scriptblockplus.item.ItemAction; 23 | import com.github.yuttyann.scriptblockplus.item.RunItem; 24 | import com.github.yuttyann.scriptblockplus.player.SBPlayer; 25 | import com.github.yuttyann.scriptblockplus.utils.ItemUtils; 26 | 27 | import org.bukkit.inventory.ItemFlag; 28 | import org.bukkit.permissions.Permissible; 29 | import org.jetbrains.annotations.NotNull; 30 | 31 | import java.util.HashSet; 32 | import java.util.Set; 33 | 34 | /** 35 | * ScriptBlockPlus ScriptViewer クラス 36 | * @author yuttyann44581 37 | */ 38 | public final class ScriptViewer extends ItemAction { 39 | 40 | public static final Set PLAYERS = new HashSet<>(); 41 | 42 | static { 43 | ScriptBlock.getScheduler().run(new TickRunnable(), 0L, 1L); 44 | } 45 | 46 | public ScriptViewer() { 47 | super(ItemUtils.getClockMaterial(), () -> "§dScript Viewer", SBConfig.SCRIPT_VIEWER::setListColor); 48 | setItemFlags(ItemFlag.HIDE_ATTRIBUTES); 49 | } 50 | 51 | @Override 52 | public void run(@NotNull RunItem runItem) { 53 | var sbPlayer = runItem.getSBPlayer(); 54 | switch (runItem.getAction()) { 55 | case LEFT_CLICK_AIR: case LEFT_CLICK_BLOCK: 56 | PLAYERS.add(sbPlayer); 57 | SBConfig.SCRIPT_VIEWER_START.send(sbPlayer); 58 | break; 59 | case RIGHT_CLICK_AIR: case RIGHT_CLICK_BLOCK: 60 | try { 61 | PLAYERS.remove(sbPlayer); 62 | TickRunnable.GLOW_ENTITY.destroyAll(sbPlayer); 63 | } catch (ReflectiveOperationException e) { 64 | e.printStackTrace(); 65 | } finally { 66 | SBConfig.SCRIPT_VIEWER_STOP.send(sbPlayer); 67 | } 68 | break; 69 | default: 70 | } 71 | } 72 | 73 | @Override 74 | public void slot(@NotNull ChangeSlot changeSlot) { } 75 | 76 | @Override 77 | public boolean hasPermission(@NotNull Permissible permissible) { 78 | return Permission.TOOL_SCRIPT_VIEWER.has(permissible); 79 | } 80 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/item/gui/custom/ToolBoxGUI.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.item.gui.custom; 17 | 18 | import java.util.concurrent.atomic.AtomicInteger; 19 | 20 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 21 | import com.github.yuttyann.scriptblockplus.item.ItemAction; 22 | import com.github.yuttyann.scriptblockplus.item.gui.CustomGUI; 23 | import com.github.yuttyann.scriptblockplus.item.gui.GUIItem; 24 | import com.github.yuttyann.scriptblockplus.item.gui.UserWindow; 25 | 26 | import org.bukkit.Sound; 27 | import org.jetbrains.annotations.NotNull; 28 | 29 | /** 30 | * ScriptBlockPlus ToolBoxGUI クラス 31 | * @author yuttyann44581 32 | */ 33 | public final class ToolBoxGUI extends CustomGUI { 34 | 35 | public ToolBoxGUI() { 36 | super(SBConfig.GUI_SYS_TOOLBOXGUI::setColor, 3, true); 37 | setSoundEffect(Sound.ENTITY_HORSE_SADDLE, 1, 1); 38 | } 39 | 40 | @Override 41 | public void onLoaded(@NotNull UserWindow window) { } 42 | 43 | @Override 44 | public void onOpened(@NotNull UserWindow window) { 45 | var index = new AtomicInteger(); 46 | ItemAction.getItems().forEach(i -> { 47 | if (i.hasPermission(window.getSBPlayer())) { 48 | window.setItem(index.getAndIncrement(), new GUIItem(i.getItem(), 49 | (w, g, c) -> w.getSBPlayer().getInventory().addItem(g.toBukkit().clone()))); 50 | } 51 | }); 52 | } 53 | 54 | @Override 55 | public void onClosed(@NotNull UserWindow window) { } 56 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/listener/trigger/BreakTrigger.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.listener.trigger; 17 | 18 | import com.github.yuttyann.scriptblockplus.BlockCoords; 19 | import com.github.yuttyann.scriptblockplus.ScriptBlock; 20 | import com.github.yuttyann.scriptblockplus.listener.TriggerListener; 21 | import com.github.yuttyann.scriptblockplus.item.ItemAction; 22 | import com.github.yuttyann.scriptblockplus.script.ScriptKey; 23 | 24 | import org.bukkit.event.EventPriority; 25 | import org.bukkit.event.block.BlockBreakEvent; 26 | import org.jetbrains.annotations.NotNull; 27 | import org.jetbrains.annotations.Nullable; 28 | 29 | /** 30 | * ScriptBlockPlus BreakTrigger クラス 31 | * @author yuttyann44581 32 | */ 33 | public final class BreakTrigger extends TriggerListener { 34 | 35 | public BreakTrigger(@NotNull ScriptBlock plugin) { 36 | super(plugin, ScriptKey.BREAK, EventPriority.HIGH); 37 | } 38 | 39 | @Override 40 | @Nullable 41 | public Trigger create(@NotNull BlockBreakEvent event) { 42 | var player = event.getPlayer(); 43 | if (ItemAction.has(player, player.getInventory().getItemInMainHand(), true)) { 44 | event.setCancelled(true); 45 | } 46 | return event.isCancelled() ? null : new Trigger(event, player, BlockCoords.of(event.getBlock())); 47 | } 48 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/listener/trigger/WalkTrigger.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.listener.trigger; 17 | 18 | import java.util.Objects; 19 | 20 | import com.github.yuttyann.scriptblockplus.BlockCoords; 21 | import com.github.yuttyann.scriptblockplus.ScriptBlock; 22 | import com.github.yuttyann.scriptblockplus.listener.TriggerListener; 23 | import com.github.yuttyann.scriptblockplus.script.ScriptKey; 24 | import com.github.yuttyann.scriptblockplus.utils.Utils; 25 | import com.github.yuttyann.scriptblockplus.utils.collection.ObjectMap; 26 | 27 | import org.bukkit.Location; 28 | import org.bukkit.event.EventPriority; 29 | import org.bukkit.event.player.PlayerMoveEvent; 30 | import org.jetbrains.annotations.NotNull; 31 | import org.jetbrains.annotations.Nullable; 32 | 33 | /** 34 | * ScriptBlockPlus WalkTrigger クラス 35 | * @author yuttyann44581 36 | */ 37 | public final class WalkTrigger extends TriggerListener { 38 | 39 | public static final String KEY = Utils.randomUUID(); 40 | 41 | public WalkTrigger(@NotNull ScriptBlock plugin) { 42 | super(plugin, ScriptKey.WALK, EventPriority.HIGH); 43 | } 44 | 45 | @Override 46 | @Nullable 47 | public Trigger create(@NotNull PlayerMoveEvent event) { 48 | var sbPlayer = ScriptBlock.getSBPlayer(event.getPlayer()); 49 | var objectMap = sbPlayer.getObjectMap(); 50 | var blockCoords = (BlockCoords) objectMap.get(KEY); 51 | return compare(objectMap, sbPlayer.getLocation(), blockCoords) ? null : new Trigger(event, sbPlayer.toPlayer(), blockCoords); 52 | } 53 | 54 | private boolean compare(@NotNull ObjectMap objectMap, @NotNull Location location, @Nullable BlockCoords blockCoords) { 55 | if (blockCoords == null) { 56 | objectMap.put(KEY, BlockCoords.of(location).subtract(0, 1, 0)); 57 | return false; 58 | } 59 | int oldX = blockCoords.getX(); 60 | int oldY = blockCoords.getY(); 61 | int oldZ = blockCoords.getZ(); 62 | if (Objects.equals(location.getWorld(), blockCoords.getWorld())) { 63 | blockCoords.setX(location.getBlockX()); 64 | blockCoords.setY(location.getBlockY() - 1); 65 | blockCoords.setZ(location.getBlockZ()); 66 | } else { 67 | objectMap.put(KEY, blockCoords = BlockCoords.of(location).subtract(0, 1, 0)); 68 | return true; 69 | } 70 | return blockCoords.compare(oldX, oldY, oldZ); 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/manager/EndProcessManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.manager; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.endprocess.EndInventory; 19 | import com.github.yuttyann.scriptblockplus.script.endprocess.EndMoneyCost; 20 | import com.github.yuttyann.scriptblockplus.script.endprocess.EndPlayerCount; 21 | import com.github.yuttyann.scriptblockplus.script.endprocess.EndProcess; 22 | 23 | import org.jetbrains.annotations.NotNull; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | import java.util.function.Consumer; 28 | import java.util.function.Supplier; 29 | 30 | /** 31 | * ScriptBlockPlus EndProcessManager クラス 32 | * @author yuttyann44581 33 | */ 34 | public final class EndProcessManager { 35 | 36 | private static final List> ENDPROCESS_LIST = new ArrayList<>(); 37 | 38 | static { 39 | register(EndPlayerCount::new); 40 | register(EndInventory::new); 41 | register(EndMoneyCost::new); 42 | } 43 | 44 | public static void register(@NotNull Supplier newInstance) { 45 | ENDPROCESS_LIST.add(new SBInstance<>(newInstance)); 46 | } 47 | 48 | public static void forEach(@NotNull Consumer action) { 49 | ENDPROCESS_LIST.forEach(c -> action.accept(c.newInstance())); 50 | } 51 | 52 | public static void forEachFinally(@NotNull Consumer action, @NotNull Runnable runnable) { 53 | try { 54 | forEach(action); 55 | } finally { 56 | runnable.run(); 57 | } 58 | } 59 | 60 | @NotNull 61 | public static EndProcess newInstance(@NotNull Class endProcess) { 62 | for (int i = 0, l = ENDPROCESS_LIST.size(); i < l; i++) { 63 | var sbInstance = ENDPROCESS_LIST.get(i); 64 | if (sbInstance.getDeclaringClass().equals(endProcess)) { 65 | return sbInstance.newInstance(); 66 | } 67 | } 68 | throw new NullPointerException(endProcess.getName() + " does not exist"); 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/manager/SBInstance.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.manager; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.util.function.Supplier; 21 | 22 | /** 23 | * ScriptBlockPlus SBInstance クラス 24 | * @param インスタンスの型 25 | * @author yuttyann44581 26 | */ 27 | @SuppressWarnings("unchecked") 28 | public final class SBInstance { 29 | 30 | private T instance; 31 | private Supplier newInstance; 32 | 33 | public SBInstance(@NotNull Supplier newInstance) { 34 | this.newInstance = newInstance; 35 | this.instance = newInstance(); 36 | } 37 | 38 | @NotNull 39 | public T get() { 40 | return (T) instance; 41 | } 42 | 43 | @NotNull 44 | public T newInstance() { 45 | return newInstance.get(); 46 | } 47 | 48 | @NotNull 49 | public Class getDeclaringClass() { 50 | return (Class) instance.getClass(); 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/player/SBPlayerMap.java: -------------------------------------------------------------------------------- 1 | package com.github.yuttyann.scriptblockplus.player; 2 | 3 | import java.util.Optional; 4 | 5 | import com.github.yuttyann.scriptblockplus.region.CuboidRegion; 6 | import com.github.yuttyann.scriptblockplus.region.Region; 7 | import com.github.yuttyann.scriptblockplus.script.SBClipboard; 8 | import com.github.yuttyann.scriptblockplus.script.ScriptEdit; 9 | import com.github.yuttyann.scriptblockplus.utils.collection.ObjectMap; 10 | 11 | import org.jetbrains.annotations.NotNull; 12 | import org.jetbrains.annotations.Nullable; 13 | 14 | /** 15 | * ScriptBlockPlus SBPlayerMap インターフェース 16 | * @author yuttyann44581 17 | */ 18 | public interface SBPlayerMap { 19 | 20 | /** 21 | * プレイヤーのデータ構造を初期化します。 22 | */ 23 | void clear(); 24 | 25 | /** 26 | * プレイヤーのデータ構造を取得します。 27 | * @return {@link ObjectMap} - データ構造 28 | */ 29 | @NotNull 30 | ObjectMap getObjectMap(); 31 | 32 | /** 33 | * プレイヤーの選択範囲を取得します。 34 | *

35 | * {@code WorldEdit}の{@code pos1}、{@code pos2}の様な機能です。 36 | * @return {@link Region} - 選択範囲 37 | */ 38 | @NotNull 39 | CuboidRegion getCuboidRegion(); 40 | 41 | /** 42 | * 編集情報を設定します。 43 | * @param scriptEdit - 編集情報 44 | */ 45 | public void setScriptEdit(@Nullable ScriptEdit scriptEdit); 46 | 47 | /** 48 | * 編集情報を取得します。 49 | * @return {@link Optional}<{@link ScriptEdit}> - 編集情報 50 | */ 51 | @NotNull 52 | public Optional getScriptEdit(); 53 | 54 | /** 55 | * クリップボードを設定します。 56 | * @param sbClipboard - クリップボード 57 | */ 58 | public void setSBClipboard(@Nullable SBClipboard sbClipboard); 59 | 60 | /** 61 | * クリップボードを取得します。 62 | * @return {@link Optional}<{@link SBClipboard}> - クリップボード 63 | */ 64 | @NotNull 65 | public Optional getSBClipboard(); 66 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/region/CuboidRegion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.region; 17 | 18 | import org.bukkit.World; 19 | import org.jetbrains.annotations.NotNull; 20 | import org.jetbrains.annotations.Nullable; 21 | 22 | import java.util.Objects; 23 | 24 | import com.github.yuttyann.scriptblockplus.BlockCoords; 25 | 26 | import static java.lang.Math.min; 27 | import static java.lang.Math.max; 28 | 29 | /** 30 | * ScriptBlockPlus CuboidRegion クラス 31 | *

32 | * {@code 位置1}と{@code 位置2}の範囲内を取得することができます。 33 | * @author yuttyann44581 34 | */ 35 | public final class CuboidRegion implements Region { 36 | 37 | private BlockCoords position1, position2; 38 | 39 | /** 40 | * {@code 位置1}を設定します。 41 | * @param position1 - 位置 42 | */ 43 | public void setPosition1(@Nullable BlockCoords position1) { 44 | this.position1 = position1; 45 | } 46 | 47 | /** 48 | * {@code 位置2}を設定します。 49 | * @param position2 - 位置2 50 | */ 51 | public void setPosition2(@Nullable BlockCoords position2) { 52 | this.position2 = position2; 53 | } 54 | 55 | @Override 56 | @Nullable 57 | public World getWorld() { 58 | if (position1 == null || position2 == null) { 59 | return null; 60 | } 61 | return Objects.equals(position1.getWorld(), position2.getWorld()) ? position1.getWorld() : null; 62 | } 63 | 64 | @Override 65 | @NotNull 66 | public String getName() { 67 | var world = getWorld(); 68 | return world == null ? "null" : world.getName(); 69 | } 70 | 71 | @Override 72 | public boolean hasPositions() { 73 | return getWorld() != null && position1 != null && position2 != null; 74 | } 75 | 76 | @Override 77 | @NotNull 78 | public BlockCoords getMinimumPoint() { 79 | double minX = min(position1.getX(), position2.getX()); 80 | double minY = min(position1.getY(), position2.getY()); 81 | double minZ = min(position1.getZ(), position2.getZ()); 82 | return BlockCoords.of(getWorld(), minX, minY, minZ); 83 | } 84 | 85 | @Override 86 | @NotNull 87 | public BlockCoords getMaximumPoint() { 88 | double maxX = max(position1.getX(), position2.getX()); 89 | double maxY = max(position1.getY(), position2.getY()); 90 | double maxZ = max(position1.getZ(), position2.getZ()); 91 | return BlockCoords.of(getWorld(), maxX, maxY, maxZ); 92 | } 93 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/region/PlayerRegion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.region; 17 | 18 | import com.github.yuttyann.scriptblockplus.BlockCoords; 19 | 20 | import org.bukkit.World; 21 | import org.bukkit.entity.Player; 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | /** 25 | * ScriptBlockPlus PlayerRegion クラス 26 | * @author yuttyann44581 27 | */ 28 | public final class PlayerRegion implements Region { 29 | 30 | private final World world; 31 | private final int x; 32 | private final int y; 33 | private final int z; 34 | private final int range; 35 | 36 | private BlockCoords min, max; 37 | 38 | public PlayerRegion(@NotNull Player player, int range) { 39 | var location = player.getLocation(); 40 | this.world = location.getWorld(); 41 | this.x = location.getBlockX(); 42 | this.y = location.getBlockY(); 43 | this.z = location.getBlockZ(); 44 | this.range = Math.max(range, 1); 45 | } 46 | 47 | @Override 48 | @NotNull 49 | public World getWorld() { 50 | return world; 51 | } 52 | 53 | @Override 54 | @NotNull 55 | public String getName() { 56 | return world == null ? "null" : world.getName(); 57 | } 58 | 59 | @Override 60 | public boolean hasPositions() { 61 | return true; 62 | } 63 | 64 | @Override 65 | @NotNull 66 | public BlockCoords getMinimumPoint() { 67 | return min == null ? this.min = BlockCoords.of(world, x - range, y - range, z - range) : min; 68 | } 69 | 70 | @Override 71 | @NotNull 72 | public BlockCoords getMaximumPoint() { 73 | return max == null ? this.max = BlockCoords.of(world, x + range, y + range, z + range) : max; 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/region/Region.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.region; 17 | 18 | import com.github.yuttyann.scriptblockplus.BlockCoords; 19 | 20 | import org.bukkit.Location; 21 | import org.bukkit.World; 22 | import org.jetbrains.annotations.NotNull; 23 | import org.jetbrains.annotations.Nullable; 24 | 25 | /** 26 | * ScriptBlockPlus Region インターフェース 27 | * @author yuttyann44581 28 | */ 29 | public interface Region { 30 | 31 | /** 32 | * ワールドを取得します。 33 | * @return {@link World} - ワールド 34 | */ 35 | @Nullable 36 | World getWorld(); 37 | 38 | /** 39 | * ワールド名を取得します。 40 | * @return {@link String} - ワールド名 41 | */ 42 | @Nullable 43 | String getName(); 44 | 45 | /** 46 | * 座標が設定されている場合は{@code true}を返します。 47 | * @return {@link Boolean} - 座標が設定されている場合は{@code true} 48 | */ 49 | boolean hasPositions(); 50 | 51 | /** 52 | * 最小座標を取得します。 53 | * @return {@link Location} - 最小座標 54 | */ 55 | @NotNull 56 | BlockCoords getMinimumPoint(); 57 | 58 | /** 59 | * 最大座標を取得します。 60 | * @return {@link Location} - 最大座標 61 | */ 62 | @NotNull 63 | BlockCoords getMaximumPoint(); 64 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/ScriptMap.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | import java.util.UUID; 24 | 25 | import com.github.yuttyann.scriptblockplus.utils.collection.ObjectMap; 26 | 27 | /** 28 | * ScriptBlockPlus ScriptMap クラス 29 | * @author yuttyann44581 30 | */ 31 | public abstract class ScriptMap implements ObjectMap { 32 | 33 | private static final Map> TEMP_MAP = new HashMap<>(); 34 | 35 | protected final UUID randomId = UUID.randomUUID(); 36 | 37 | @Override 38 | public void put(@NotNull String key, @Nullable Object value) { 39 | TEMP_MAP.computeIfAbsent(randomId, v -> new HashMap<>()).put(key, value); 40 | } 41 | 42 | @Override 43 | @Nullable 44 | @SuppressWarnings("unchecked") 45 | public T get(@NotNull String key) { 46 | var map = TEMP_MAP.get(randomId); 47 | return map == null ? null : (T) map.get(key); 48 | } 49 | 50 | @Override 51 | public void remove(@NotNull String key) { 52 | TEMP_MAP.get(randomId).remove(key); 53 | } 54 | 55 | @Override 56 | public void clear() { 57 | TEMP_MAP.remove(randomId); 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/endprocess/EndInventory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.endprocess; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 19 | import com.github.yuttyann.scriptblockplus.script.option.other.ItemCost; 20 | 21 | import org.bukkit.inventory.ItemStack; 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | /** 25 | * ScriptBlockPlus EndInventory エンドプロセスクラス 26 | * @author yuttyann44581 27 | */ 28 | public final class EndInventory implements EndProcess { 29 | 30 | private static final ItemStack[] EMPTY_ARRAY = new ItemStack[0]; 31 | 32 | @Override 33 | public void success(@NotNull ScriptRead scriptRead) { 34 | var sbPlayer = scriptRead.getSBPlayer(); 35 | if (sbPlayer.isOnline()) { 36 | sbPlayer.toPlayer().updateInventory(); 37 | } 38 | } 39 | 40 | @Override 41 | public void failed(@NotNull ScriptRead scriptRead) { 42 | var sbPlayer = scriptRead.getSBPlayer(); 43 | var inventoryItems = scriptRead.get(ItemCost.KEY_OPTION, EMPTY_ARRAY); 44 | if (inventoryItems.length > 0 && sbPlayer.isOnline()) { 45 | sbPlayer.getInventory().setContents(inventoryItems); 46 | sbPlayer.toPlayer().updateInventory(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/endprocess/EndMoneyCost.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.endprocess; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultEconomy; 19 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 20 | import com.github.yuttyann.scriptblockplus.script.option.vault.MoneyCost; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | /** 24 | * ScriptBlockPlus EndMoneyCost エンドプロセスクラス 25 | * @author yuttyann44581 26 | */ 27 | public final class EndMoneyCost implements EndProcess { 28 | 29 | @Override 30 | public void success(@NotNull ScriptRead scriptRead) { } 31 | 32 | @Override 33 | public void failed(@NotNull ScriptRead scriptRead) { 34 | var economy = VaultEconomy.INSTANCE; 35 | if (economy.isEnabled() && scriptRead.has(MoneyCost.KEY)) { 36 | economy.depositPlayer(scriptRead.getSBPlayer().toOfflinePlayer(), scriptRead.getDouble(MoneyCost.KEY)); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/endprocess/EndPlayerCount.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.endprocess; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.json.derived.PlayerCountJson; 19 | import com.github.yuttyann.scriptblockplus.file.json.derived.element.PlayerCount; 20 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 21 | 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | /** 25 | * ScriptBlockPlus EndPlayerCount エンドプロセスクラス 26 | * @author yuttyann44581 27 | */ 28 | public class EndPlayerCount implements EndProcess { 29 | 30 | @Override 31 | public void success(@NotNull ScriptRead scriptRead) { 32 | PlayerCountJson.get(scriptRead.getSBPlayer().getUniqueId()).action(PlayerCount::add, scriptRead.getScriptKey(), scriptRead.getBlockCoords()); 33 | } 34 | 35 | @Override 36 | public void failed(@NotNull ScriptRead scriptRead) { } 37 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/endprocess/EndProcess.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.endprocess; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | /** 22 | * ScriptBlockPlus EndProcess インターフェース 23 | * @author yuttyann44581 24 | */ 25 | public interface EndProcess { 26 | 27 | /** 28 | * スクリプトの実行が最後まで成功した場合に呼び出されます。 29 | * @param scriptRead - {@link ScriptRead} 30 | */ 31 | void success(@NotNull ScriptRead scriptRead); 32 | 33 | /** 34 | * スクリプトの実行が途中で失敗した場合に呼び出されます。 35 | * @param scriptRead - {@link ScriptRead} 36 | */ 37 | void failed(@NotNull ScriptRead scriptRead); 38 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/OptionIndex.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.IndexType; 19 | import org.jetbrains.annotations.NotNull; 20 | import org.jetbrains.annotations.Nullable; 21 | 22 | /** 23 | * ScriptBlockPlus OptionIndex クラス 24 | * @author yuttyann44581 25 | */ 26 | public final class OptionIndex { 27 | 28 | private final IndexType indexType; 29 | private final OptionTag optionTag; 30 | 31 | /** 32 | * コンストラクタ 33 | * @param indexType - スクリプトの追加位置 34 | * @param optionTag - オプションタグ 35 | */ 36 | private OptionIndex(@NotNull IndexType indexType, @Nullable OptionTag optionTag) { 37 | this.indexType = indexType; 38 | this.optionTag = optionTag; 39 | } 40 | 41 | /** 42 | * オプションを先頭に追加します。 43 | * @return {@link OptionIndex} - オプションインデックス 44 | */ 45 | @NotNull 46 | public static OptionIndex top() { 47 | return new OptionIndex(IndexType.TOP, null); 48 | } 49 | 50 | /** 51 | * オプションを最後尾に追加します。 52 | * @return {@link OptionIndex} - オプションインデックス 53 | */ 54 | @NotNull 55 | public static OptionIndex last() { 56 | return new OptionIndex(IndexType.LAST, null); 57 | } 58 | 59 | /** 60 | * 指定したオプションより一つ前に追加します。 61 | * @param optionClass - オプションのクラス 62 | * @return {@link OptionIndex} - オプションインデックス 63 | */ 64 | @NotNull 65 | public static OptionIndex before(@NotNull Class optionClass) { 66 | return new OptionIndex(IndexType.BEFORE, optionClass.getAnnotation(OptionTag.class)); 67 | } 68 | 69 | /** 70 | * 指定したオプションより一つ後に追加します。 71 | * @param optionClass - オプションのクラス 72 | * @return {@link OptionIndex} - オプションインデックス 73 | */ 74 | @NotNull 75 | public static OptionIndex after(@NotNull Class optionClass) { 76 | return new OptionIndex(IndexType.AFTER, optionClass.getAnnotation(OptionTag.class)); 77 | } 78 | 79 | /** 80 | * オプションタグを取得します。 81 | * @return {@link OptionTag} - オプションタグ 82 | */ 83 | @Nullable 84 | public OptionTag getOptionTag() { 85 | return optionTag; 86 | } 87 | 88 | /** 89 | * オプションの追加位置を取得します。 90 | * @return {@link IndexType} - オプションの追加位置 91 | */ 92 | @NotNull 93 | public IndexType getIndexType() { 94 | return indexType; 95 | } 96 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/OptionTag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.Target; 22 | 23 | import static java.lang.annotation.ElementType.TYPE; 24 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 25 | 26 | /** 27 | * ScriptBlockPlus OptionTag 注釈 28 | * @author yuttyann44581 29 | */ 30 | @Target(TYPE) 31 | @Retention(RUNTIME) 32 | public @interface OptionTag { 33 | 34 | /** 35 | * オプションの名前を取得します。 36 | * @return {@link String} - オプションの名前 37 | */ 38 | @NotNull 39 | String name(); 40 | 41 | /** 42 | * オプションの構文を取得します。 43 | * @return {@link String} - オプションの構文 44 | */ 45 | @NotNull 46 | String syntax(); 47 | 48 | /** 49 | * オプションの説明を取得します。 50 | * @return {@link String} - オプションの説明 51 | */ 52 | @NotNull 53 | String description() default ""; 54 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/chat/BypassOP.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.chat; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.CommandLog; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import com.github.yuttyann.scriptblockplus.utils.Utils; 22 | 23 | /** 24 | * ScriptBlockPlus BypassOP オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "bypassop", syntax = "@bypass ", description = "") 28 | public final class BypassOP extends BaseOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | var player = getSBPlayer().toPlayer(); 33 | var command = setColor(getOptionValue(), true); 34 | return CommandLog.supplier(player.getWorld(), () -> { 35 | if (player.isOp()) { 36 | return toResult(Utils.dispatchCommand(player, getLocation(), command)); 37 | } else { 38 | try { 39 | player.setOp(true); 40 | return toResult(Utils.dispatchCommand(player, getLocation(), command)); 41 | } finally { 42 | player.setOp(false); 43 | } 44 | } 45 | }); 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/chat/Command.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.chat; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.CommandLog; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import com.github.yuttyann.scriptblockplus.utils.Utils; 22 | 23 | /** 24 | * ScriptBlockPlus Command オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "command", syntax = "@command ", description = "") 28 | public final class Command extends BaseOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | var player = getSBPlayer().toPlayer(); 33 | var command = setColor(getOptionValue(), true); 34 | return CommandLog.supplier(player.getWorld(), () -> toResult(Utils.dispatchCommand(player, getLocation(), command))); 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/chat/Console.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.chat; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.CommandLog; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import com.github.yuttyann.scriptblockplus.utils.Utils; 22 | import org.bukkit.Bukkit; 23 | 24 | /** 25 | * ScriptBlockPlus Console オプションクラス 26 | * @author yuttyann44581 27 | */ 28 | @OptionTag(name = "console", syntax = "@console ", description = "") 29 | public final class Console extends BaseOption { 30 | 31 | @Override 32 | protected Result isValid() throws Exception { 33 | var command = setColor(getOptionValue(), true); 34 | return CommandLog.supplier(getSBPlayer().getWorld(), () -> toResult(Utils.dispatchCommand(Bukkit.getConsoleSender(), getLocation(), command))); 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/chat/Say.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.chat; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.Permission; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import com.github.yuttyann.scriptblockplus.utils.Utils; 22 | 23 | /** 24 | * ScriptBlockPlus Say オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "say", syntax = "@say ", description = "") 28 | public final class Say extends BaseOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | var command = "minecraft:say " + setColor(getOptionValue(), true); 33 | var sbPlayer = getSBPlayer(); 34 | return Utils.tempPerm(sbPlayer, Permission.MINECRAFT_COMMAND_SAY, () -> toResult(Utils.dispatchCommand(sbPlayer.toPlayer(), getLocation(), command))); 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/chat/Server.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.chat; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 19 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 20 | import org.bukkit.Bukkit; 21 | 22 | /** 23 | * ScriptBlockPlus Server オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "server", syntax = "@server ", description = "") 27 | public final class Server extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | Bukkit.broadcastMessage(setColor(getOptionValue(), true)); 32 | return Result.SUCCESS; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/chat/Title.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.chat; 17 | 18 | import static com.github.yuttyann.scriptblockplus.utils.version.McVersion.*; 19 | 20 | import org.bukkit.Bukkit; 21 | import org.jetbrains.annotations.NotNull; 22 | import org.jetbrains.annotations.Nullable; 23 | 24 | import com.github.yuttyann.scriptblockplus.enums.Permission; 25 | import com.github.yuttyann.scriptblockplus.player.SBPlayer; 26 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 27 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 28 | import com.github.yuttyann.scriptblockplus.utils.Utils; 29 | 30 | /** 31 | * ScriptBlockPlus Title オプションクラス 32 | * @author yuttyann44581 33 | */ 34 | @OptionTag(name = "title", syntax = "@title:", description = "

[/sub][/fadeIn-stay-fadeout]") 35 | public final class Title extends BaseOption { 36 | 37 | @Override 38 | protected Result isValid() throws Exception { 39 | var slash = split(getOptionValue(), '/', false); 40 | var title = setColor(slash.get(0), true); 41 | var subtitle = setColor(slash.size() > 1 ? slash.get(1) : "", true); 42 | int fadeIn = 10, stay = 40, fadeOut = 10; 43 | if (slash.size() == 3) { 44 | var times = split(slash.get(2), '-', false); 45 | if (times.size() == 3) { 46 | fadeIn = Integer.parseInt(times.get(0)); 47 | stay = Integer.parseInt(times.get(1)); 48 | fadeOut = Integer.parseInt(times.get(2)); 49 | } 50 | } 51 | send(getSBPlayer(), title, subtitle, fadeIn, stay, fadeOut); 52 | return Result.SUCCESS; 53 | } 54 | 55 | public static void send(@NotNull SBPlayer sbPlayer, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) { 56 | var player = sbPlayer.toPlayer(); 57 | if (V_1_12.isSupported()) { 58 | player.sendTitle(title, subtitle, fadeIn, stay, fadeOut); 59 | } else { 60 | var prefix = "minecraft:title " + sbPlayer.getName(); 61 | Utils.tempPerm(sbPlayer, Permission.MINECRAFT_COMMAND_TITLE, () -> { 62 | Bukkit.dispatchCommand(player, prefix + " times " + fadeIn + " " + stay + " " + fadeOut); 63 | Bukkit.dispatchCommand(player, prefix + " subtitle {\"text\":\"" + subtitle + "\"}"); 64 | Bukkit.dispatchCommand(player, prefix + " title {\"text\":\"" + title + "\"}"); 65 | return true; 66 | }); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/chat/ToPlayer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.chat; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 19 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 20 | import com.github.yuttyann.scriptblockplus.utils.Utils; 21 | 22 | /** 23 | * ScriptBlockPlus ToPlayer オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "toplayer", syntax = "@player ", description = "") 27 | public final class ToPlayer extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | Utils.sendColorMessage(getSBPlayer().toPlayer(), escape(getOptionValue())); 32 | return Result.SUCCESS; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/discord/DiscordChannel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.discord; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.DiscordSRV; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | 22 | /** 23 | * ScriptBlockPlus DiscordChannel オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "discordchannel", syntax = "@dchannel:", description = "") 27 | public class DiscordChannel extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | if (!DiscordSRV.INSTANCE.isEnabled()) { 32 | throw new UnsupportedOperationException("Invalid function"); 33 | } 34 | var channelId = DiscordSRV.INSTANCE.getVoiceChannelId(getUniqueId()); 35 | return toResult(channelId == null ? false : channelId.equals(getOptionValue())); 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/discord/DiscordRole.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.discord; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.DiscordSRV; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import com.github.yuttyann.scriptblockplus.utils.StreamUtils; 22 | 23 | /** 24 | * ScriptBlockPlus DiscordRole オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "discordrole", syntax = "@drole:", description = "") 28 | public class DiscordRole extends BaseOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | if (!DiscordSRV.INSTANCE.isEnabled()) { 33 | throw new UnsupportedOperationException("Invalid function"); 34 | } 35 | var roles = DiscordSRV.INSTANCE.getRoles(getUniqueId()); 36 | return toResult(roles.length > 0 && StreamUtils.anyMatch(roles, r -> r.equals(getOptionValue()))); 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/discord/DiscordRoleAdd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.discord; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.DiscordSRV; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | 22 | /** 23 | * ScriptBlockPlus DiscordRoleAdd オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "discordroleadd", syntax = "@droleADD:", description = "") 27 | public class DiscordRoleAdd extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | if (!DiscordSRV.INSTANCE.isEnabled()) { 32 | throw new UnsupportedOperationException("Invalid function"); 33 | } 34 | var comma = split(getOptionValue(), ',', false); 35 | DiscordSRV.INSTANCE.addRoleToMember(getUniqueId(), comma.toArray(String[]::new)); 36 | return Result.SUCCESS; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/discord/DiscordRoleRemove.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.discord; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.DiscordSRV; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | 22 | /** 23 | * ScriptBlockPlus DiscordRoleRemove オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "discordroleremove", syntax = "@droleREMOVE:", description = "") 27 | public class DiscordRoleRemove extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | if (!DiscordSRV.INSTANCE.isEnabled()) { 32 | throw new UnsupportedOperationException("Invalid function"); 33 | } 34 | var comma = split(getOptionValue(), ',', false); 35 | DiscordSRV.INSTANCE.removeRoleToMember(getUniqueId(), comma.toArray(String[]::new)); 36 | return Result.SUCCESS; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/other/Amount.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.other; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.json.derived.BlockScriptJson; 19 | import com.github.yuttyann.scriptblockplus.file.json.derived.element.BlockScript; 20 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 21 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 22 | 23 | /** 24 | * ScriptBlockPlus Amount オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "amount", syntax = "@amount:", description = "") 28 | public final class Amount extends BaseOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | var scriptJson = BlockScriptJson.get(getScriptKey()); 33 | var blockCoords = getBlockCoords(); 34 | var blockScript = scriptJson.load(blockCoords); 35 | 36 | var amount = blockScript.getSafeValue(BlockScript.AMOUNT).asInt(Integer.parseInt(getOptionValue())) - 1; 37 | if (amount > 0) { 38 | blockScript.setValue(BlockScript.AMOUNT, amount); 39 | } else { 40 | if (scriptJson.remove(blockCoords)) { 41 | scriptJson.init(blockCoords); 42 | } 43 | } 44 | scriptJson.saveJson(); 45 | return Result.SUCCESS; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/other/BlockType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.other; 17 | 18 | import org.bukkit.block.Block; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 22 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 23 | import com.github.yuttyann.scriptblockplus.utils.ItemUtils; 24 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 25 | import com.github.yuttyann.scriptblockplus.utils.Utils; 26 | 27 | /** 28 | * ScriptBlockPlus BlockType オプションクラス 29 | * @author yuttyann44581 30 | */ 31 | @OptionTag(name = "blocktype", syntax = "@blocktype:", description = "") 32 | public final class BlockType extends BaseOption { 33 | 34 | @Override 35 | protected Result isValid() throws Exception { 36 | var block = getBlockCoords().getBlock(); 37 | for (var value : split(getOptionValue(), ',', false)) { 38 | if (equals(block, value)) { 39 | return Result.SUCCESS; 40 | } 41 | } 42 | return Result.FAILURE; 43 | } 44 | 45 | private boolean equals(@NotNull Block block, @NotNull String type) throws IllegalAccessException { 46 | if (StringUtils.isEmpty(type)) { 47 | return false; 48 | } 49 | var blockId = StringUtils.removeStart(type, Utils.MINECRAFT); 50 | if (IfAction.REALNUMBER_PATTERN.matcher(blockId).matches()) { 51 | throw new IllegalAccessException("Numerical values can not be used"); 52 | } 53 | var material = ItemUtils.getMaterial(blockId); 54 | return material != null && material.isBlock() && material == block.getType(); 55 | } 56 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/other/EventInvalid.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.other; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 19 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 20 | 21 | /** 22 | * ScriptBlockPlus EventInvalid オプションクラス 23 | * @author yuttyann44581 24 | */ 25 | @OptionTag(name = "invalid", syntax = "@invalid") 26 | public final class EventInvalid extends BaseOption { 27 | 28 | @Override 29 | protected Result isValid() throws Exception { 30 | return Result.SUCCESS; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/other/Execute.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.other; 17 | 18 | import com.github.yuttyann.scriptblockplus.BlockCoords; 19 | import com.github.yuttyann.scriptblockplus.script.ScriptKey; 20 | import com.github.yuttyann.scriptblockplus.script.ScriptRead; 21 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 22 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 23 | 24 | /** 25 | * ScriptBlockPlus Execute オプションクラス 26 | * @author yuttyann44581 27 | */ 28 | @OptionTag(name = "execute", syntax = "@execute:", description = "/") 29 | public final class Execute extends BaseOption { 30 | 31 | @Override 32 | protected Result isValid() throws Exception { 33 | var slash = split(getOptionValue(), '/', false); 34 | return toResult(new ScriptRead(getSBPlayer(), BlockCoords.fromString(slash.get(1)), ScriptKey.valueOf(slash.get(0))).read(0)); 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/other/ItemHand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.other; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import com.github.yuttyann.scriptblockplus.utils.Utils; 22 | 23 | import org.bukkit.inventory.ItemStack; 24 | 25 | import static com.github.yuttyann.scriptblockplus.enums.MatchType.*; 26 | import static com.github.yuttyann.scriptblockplus.utils.ItemUtils.*; 27 | import static com.github.yuttyann.scriptblockplus.utils.StringUtils.*; 28 | 29 | /** 30 | * ScriptBlockPlus ItemHand オプションクラス 31 | * @author yuttyann44581 32 | */ 33 | @OptionTag(name = "itemhand", syntax = "@hand:", description = "[:damage] [name] [lore]") 34 | public final class ItemHand extends BaseOption { 35 | 36 | @Override 37 | protected Result isValid() throws Exception { 38 | var space = split(getOptionValue(), ' ', false); 39 | var itemId = split(removeStart(space.get(0), Utils.MINECRAFT), ':', false); 40 | if (IfAction.REALNUMBER_PATTERN.matcher(itemId.get(0)).matches()) { 41 | throw new IllegalAccessException("Numerical values can not be used"); 42 | } 43 | var material = getMaterial(itemId.get(0)); 44 | int damage = itemId.size() > 1 ? Integer.parseInt(itemId.get(1)) : -1; 45 | int amount = Integer.parseInt(space.get(1)); 46 | var name = space.size() > 2 ? escape(space.get(2)) : null; 47 | var lore = space.size() > 3 ? escape(space.get(3)) : null; 48 | 49 | var inventory = getSBPlayer().getInventory(); 50 | for (var hand : new ItemStack[] { inventory.getItemInMainHand(), inventory.getItemInOffHand() }) { 51 | if (!compare(AMOUNT, hand, amount) 52 | || !compare(TYPE, hand, material) 53 | || damage != -1 && !compare(META, hand, damage) 54 | || name != null && !compare(NAME, hand, name) 55 | || lore != null && !compare(LORE, hand, lore)) { 56 | continue; 57 | } 58 | return Result.SUCCESS; 59 | } 60 | sendMessage(SBConfig.ERROR_HAND.replace(material, amount, damage, name, lore)); 61 | return Result.FAILURE; 62 | } 63 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/other/PlayerAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.other; 17 | 18 | import com.github.yuttyann.scriptblockplus.script.ScriptKey; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import com.github.yuttyann.scriptblockplus.utils.StreamUtils; 22 | import com.github.yuttyann.scriptblockplus.utils.Utils; 23 | import org.bukkit.event.block.Action; 24 | import org.jetbrains.annotations.NotNull; 25 | import org.jetbrains.annotations.Nullable; 26 | 27 | /** 28 | * ScriptBlockPlus ScriptAction オプションクラス 29 | * @author yuttyann44581 30 | */ 31 | @OptionTag(name = "action", syntax = "@action:", description = "") 32 | public final class PlayerAction extends BaseOption { 33 | 34 | public static final String KEY = Utils.randomUUID(); 35 | 36 | @Override 37 | protected Result isValid() throws Exception { 38 | if (!getTempMap().has(KEY)) { 39 | return Result.FAILURE; 40 | } 41 | var action = (Action) getTempMap().get(KEY); 42 | return toResult(StreamUtils.allMatch(split(getOptionValue(), ',', false), s -> compare(action, s))); 43 | } 44 | 45 | private boolean compare(@Nullable Action action, @NotNull String type) { 46 | return type.equalsIgnoreCase("shift") ? getSBPlayer().toPlayer().isSneaking() : ScriptKey.INTERACT.equals(getScriptKey()) && action == getAction(type); 47 | } 48 | 49 | @Nullable 50 | private Action getAction(@NotNull String action) { 51 | return action.equalsIgnoreCase("left") ? Action.LEFT_CLICK_BLOCK : action.equalsIgnoreCase("right") ? Action.RIGHT_CLICK_BLOCK : null; 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/time/Cooldown.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.time; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.json.derived.PlayerTimerJson; 19 | import com.github.yuttyann.scriptblockplus.file.json.derived.element.PlayerTimer; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import org.jetbrains.annotations.Nullable; 22 | 23 | /** 24 | * ScriptBlockPlus Cooldown オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "cooldown", syntax = "@cooldown:", description = "") 28 | public final class Cooldown extends TimerOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | if (inCooldown()) { 33 | return Result.FAILURE; 34 | } 35 | var time = new long[] { System.currentTimeMillis(), Integer.parseInt(getOptionValue()) * 1000L, 0L }; 36 | time[2] = time[0] + time[1]; 37 | 38 | var timerJson = PlayerTimerJson.get(getFileUniqueId()); 39 | timerJson.load(getFileUniqueId(), getScriptKey(), getBlockCoords()).setTime(time); 40 | timerJson.saveJson(); 41 | return Result.SUCCESS; 42 | } 43 | 44 | @Override 45 | @Nullable 46 | protected PlayerTimer getPlayerTimer() { 47 | return PlayerTimerJson.get(getFileUniqueId()).load(getFileUniqueId(), getScriptKey(), getBlockCoords()); 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/time/OldCooldown.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.time; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.json.derived.PlayerTimerJson; 19 | import com.github.yuttyann.scriptblockplus.file.json.derived.element.PlayerTimer; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | import org.jetbrains.annotations.NotNull; 22 | import org.jetbrains.annotations.Nullable; 23 | 24 | import java.util.UUID; 25 | 26 | /** 27 | * ScriptBlockPlus OldCooldown オプションクラス 28 | * @author yuttyann44581 29 | */ 30 | @OptionTag(name = "oldcooldown", syntax = "@oldcooldown:", description = "") 31 | public final class OldCooldown extends TimerOption { 32 | 33 | public static final UUID UUID_OLDCOOLDOWN = UUID.nameUUIDFromBytes(OldCooldown.class.getName().getBytes()); 34 | 35 | @Override 36 | protected Result isValid() throws Exception { 37 | if (inCooldown()) { 38 | return Result.FAILURE; 39 | } 40 | var time = new long[] { System.currentTimeMillis(), Integer.parseInt(getOptionValue()) * 1000L, 0L }; 41 | time[2] = time[0] + time[1]; 42 | 43 | var timerJson = PlayerTimerJson.get(getFileUniqueId()); 44 | timerJson.load(null, getScriptKey(), getBlockCoords()).setTime(time); 45 | timerJson.saveJson(); 46 | return Result.SUCCESS; 47 | } 48 | 49 | @Override 50 | @NotNull 51 | protected UUID getFileUniqueId() { 52 | return UUID_OLDCOOLDOWN; 53 | } 54 | 55 | @Override 56 | @Nullable 57 | protected PlayerTimer getPlayerTimer() { 58 | return PlayerTimerJson.get(getFileUniqueId()).load(null, getScriptKey(), getBlockCoords()); 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/time/TimerOption.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.time; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 19 | import com.github.yuttyann.scriptblockplus.file.json.derived.element.PlayerTimer; 20 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 21 | 22 | import org.jetbrains.annotations.NotNull; 23 | import org.jetbrains.annotations.Nullable; 24 | 25 | import java.util.UUID; 26 | 27 | /** 28 | * ScriptBlockPlus TimerOption オプションクラス 29 | * @author yuttyann44581 30 | */ 31 | public abstract class TimerOption extends BaseOption { 32 | 33 | @Nullable 34 | protected abstract PlayerTimer getPlayerTimer(); 35 | 36 | @NotNull 37 | protected UUID getFileUniqueId() { 38 | return getUniqueId(); 39 | } 40 | 41 | protected boolean inCooldown() { 42 | var playerTimer = getPlayerTimer(); 43 | if (playerTimer != null) { 44 | int time = playerTimer.getSecond(); 45 | if (time > 0) { 46 | short hour = (short) (time / 3600); 47 | byte minute = (byte) (time % 3600 / 60); 48 | byte second = (byte) (time % 3600 % 60); 49 | sendMessage(SBConfig.ACTIVE_COOLDOWN.replace(hour, minute, second)); 50 | return true; 51 | } 52 | } 53 | return false; 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/BypassGroup.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.CommandLog; 19 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 20 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 21 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 22 | import com.github.yuttyann.scriptblockplus.utils.Utils; 23 | 24 | /** 25 | * ScriptBlockPlus BypassGroup オプションクラス 26 | * @author yuttyann44581 27 | */ 28 | @OptionTag(name = "bypassgroup", syntax = "@bypassGROUP:", description = "[world] ") 29 | public final class BypassGroup extends BaseOption { 30 | 31 | @Override 32 | protected Result isValid() throws Exception { 33 | var vaultPermission = VaultPermission.INSTANCE; 34 | if (!vaultPermission.isEnabled() || vaultPermission.isSuperPerms()) { 35 | throw new UnsupportedOperationException("Invalid function"); 36 | } 37 | var player = getSBPlayer().toPlayer(); 38 | var value = getOptionValue(); 39 | int index = value.indexOf(" "); 40 | var slash = split(value.substring(0, index), '/', true); 41 | var world = slash.size() > 1 ? slash.get(0) : null; 42 | var group = slash.size() > 1 ? slash.get(1) : slash.get(0); 43 | var command = escape(value.substring(index + 1, value.length())); 44 | return CommandLog.supplier(player.getWorld(), () -> { 45 | if (vaultPermission.playerInGroup(world, player, group)) { 46 | return toResult(Utils.dispatchCommand(player, getLocation(), command)); 47 | } else { 48 | try { 49 | vaultPermission.playerAddGroup(world, player, group); 50 | return toResult(Utils.dispatchCommand(player, getLocation(), command)); 51 | } finally { 52 | vaultPermission.playerRemoveGroup(world, player, group); 53 | } 54 | } 55 | }); 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/BypassPerm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.CommandLog; 19 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 20 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 21 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 22 | import com.github.yuttyann.scriptblockplus.utils.Utils; 23 | 24 | /** 25 | * ScriptBlockPlus BypassPerm オプションクラス 26 | * @author yuttyann44581 27 | */ 28 | @OptionTag(name = "bypassperm", syntax = "@bypassPERM:", description = "[world] ") 29 | public final class BypassPerm extends BaseOption { 30 | 31 | @Override 32 | protected Result isValid() throws Exception { 33 | var vaultPermission = VaultPermission.INSTANCE; 34 | if (!vaultPermission.isEnabled() || vaultPermission.isSuperPerms()) { 35 | throw new UnsupportedOperationException("Invalid function"); 36 | } 37 | var player = getSBPlayer().toPlayer(); 38 | var value = getOptionValue(); 39 | int index = value.indexOf(" "); 40 | var slash = split(value.substring(0, index), '/', true); 41 | var world = slash.size() > 1 ? slash.get(0) : null; 42 | var permission = slash.size() > 1 ? slash.get(1) : slash.get(0); 43 | var command = escape(value.substring(index + 1, value.length())); 44 | return CommandLog.supplier(player.getWorld(), () -> { 45 | if (vaultPermission.playerHas(world, player, permission)) { 46 | return toResult(Utils.dispatchCommand(player, getLocation(), command)); 47 | } else { 48 | try { 49 | vaultPermission.playerAdd(world, player, permission); 50 | return toResult(Utils.dispatchCommand(player, getLocation(), command)); 51 | } finally { 52 | vaultPermission.playerRemove(world, player, permission); 53 | } 54 | } 55 | }); 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/Group.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 19 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 20 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 21 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 22 | 23 | /** 24 | * ScriptBlockPlus Group オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "group", syntax = "@group:", description = "[world/]") 28 | public final class Group extends BaseOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | var vaultPermission = VaultPermission.INSTANCE; 33 | if (!vaultPermission.isEnabled() || vaultPermission.isSuperPerms()) { 34 | throw new UnsupportedOperationException("Invalid function"); 35 | } 36 | var slash = split(getOptionValue(), '/', true); 37 | var world = slash.size() > 1 ? slash.get(0) : null; 38 | var group = slash.size() > 1 ? slash.get(1) : slash.get(0); 39 | 40 | if (!vaultPermission.playerInGroup(world, getSBPlayer().toPlayer(), group)) { 41 | sendMessage(SBConfig.ERROR_GROUP.replace(getOptionValue())); 42 | return Result.FAILURE; 43 | } 44 | return Result.SUCCESS; 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/GroupAdd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | 22 | /** 23 | * ScriptBlockPlus GroupAdd オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "groupadd", syntax = "@groupADD:", description = "[world/]") 27 | public final class GroupAdd extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | var vaultPermission = VaultPermission.INSTANCE; 32 | if (!vaultPermission.isEnabled() || vaultPermission.isSuperPerms()) { 33 | throw new UnsupportedOperationException("Invalid function"); 34 | } 35 | var slash = split(getOptionValue(), '/', true); 36 | var world = slash.size() > 1 ? slash.get(0) : null; 37 | var group = slash.size() > 1 ? slash.get(1) : slash.get(0); 38 | 39 | var player = getSBPlayer().toPlayer(); 40 | if (!vaultPermission.playerInGroup(world, player, group)) { 41 | vaultPermission.playerAddGroup(world, player, group); 42 | } 43 | return Result.SUCCESS; 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/GroupRemove.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | 22 | /** 23 | * ScriptBlockPlus GroupRemove オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "groupremove", syntax = "@groupREMOVE:", description = "[world/]") 27 | public final class GroupRemove extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | var vaultPermission = VaultPermission.INSTANCE; 32 | if (!vaultPermission.isEnabled() || vaultPermission.isSuperPerms()) { 33 | throw new UnsupportedOperationException("Invalid function"); 34 | } 35 | var slash = split(getOptionValue(), '/', true); 36 | var world = slash.size() > 1 ? slash.get(0) : null; 37 | var group = slash.size() > 1 ? slash.get(1) : slash.get(0); 38 | 39 | var player = getSBPlayer().toPlayer(); 40 | if (vaultPermission.playerInGroup(world, player, group)) { 41 | vaultPermission.playerRemoveGroup(world, player, group); 42 | } 43 | return Result.SUCCESS; 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/MoneyCost.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 19 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultEconomy; 20 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 21 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 22 | import com.github.yuttyann.scriptblockplus.utils.Utils; 23 | 24 | /** 25 | * ScriptBlockPlus MoneyCost オプションクラス 26 | * @author yuttyann44581 27 | */ 28 | @OptionTag(name = "moneycost", syntax = "$cost:", description = "") 29 | public final class MoneyCost extends BaseOption { 30 | 31 | public static final String KEY = Utils.randomUUID(); 32 | 33 | @Override 34 | protected Result isValid() throws Exception { 35 | var vaultEconomy = VaultEconomy.INSTANCE; 36 | if (!vaultEconomy.isEnabled()) { 37 | throw new UnsupportedOperationException("Invalid function"); 38 | } 39 | var player = getSBPlayer().toPlayer(); 40 | double cost = Double.parseDouble(getOptionValue()); 41 | if (vaultEconomy.has(player, cost)) { 42 | vaultEconomy.withdrawPlayer(player, cost); 43 | getTempMap().put(KEY, cost + (getTempMap().has(KEY) ? getTempMap().getDouble(KEY) : 0.0D)); 44 | return Result.SUCCESS; 45 | } 46 | sendMessage(SBConfig.ERROR_COST.replace(cost, cost - vaultEconomy.getBalance(player))); 47 | return Result.FAILURE; 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/Perm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.file.config.SBConfig; 19 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 20 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 21 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 22 | 23 | /** 24 | * ScriptBlockPlus Perm オプションクラス 25 | * @author yuttyann44581 26 | */ 27 | @OptionTag(name = "permission", syntax = "@perm:", description = "[world/]") 28 | public final class Perm extends BaseOption { 29 | 30 | @Override 31 | protected Result isValid() throws Exception { 32 | var vaultPermission = VaultPermission.INSTANCE; 33 | if (!vaultPermission.isEnabled()) { 34 | throw new UnsupportedOperationException("Invalid function"); 35 | } 36 | var slash = split(getOptionValue(), '/', true); 37 | var world = slash.size() > 1 ? slash.get(0) : null; 38 | var permission = slash.size() > 1 ? slash.get(1) : slash.get(0); 39 | 40 | if (!vaultPermission.playerHas(world, getSBPlayer().toPlayer(), permission)) { 41 | sendMessage(SBConfig.NOT_PERMISSION); 42 | return Result.FAILURE; 43 | } 44 | return Result.SUCCESS; 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/PermAdd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | 22 | /** 23 | * ScriptBlockPlus PermAdd オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "permadd", syntax = "@permADD:", description = "[world/]") 27 | public final class PermAdd extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | var vaultPermission = VaultPermission.INSTANCE; 32 | if (!vaultPermission.isEnabled() || vaultPermission.isSuperPerms()) { 33 | throw new UnsupportedOperationException("Invalid function"); 34 | } 35 | var slash = split(getOptionValue(), '/', true); 36 | var world = slash.size() > 1 ? slash.get(0) : null; 37 | var permission = slash.size() > 1 ? slash.get(1) : slash.get(0); 38 | vaultPermission.playerAdd(world, getSBPlayer().toPlayer(), permission); 39 | return Result.SUCCESS; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/script/option/vault/PermRemove.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.script.option.vault; 17 | 18 | import com.github.yuttyann.scriptblockplus.hook.plugin.VaultPermission; 19 | import com.github.yuttyann.scriptblockplus.script.option.BaseOption; 20 | import com.github.yuttyann.scriptblockplus.script.option.OptionTag; 21 | 22 | /** 23 | * ScriptBlockPlus PermRemove オプションクラス 24 | * @author yuttyann44581 25 | */ 26 | @OptionTag(name = "permremove", syntax = "@permREMOVE:", description = "[world/]") 27 | public final class PermRemove extends BaseOption { 28 | 29 | @Override 30 | protected Result isValid() throws Exception { 31 | var vaultPermission = VaultPermission.INSTANCE; 32 | if (!vaultPermission.isEnabled() || vaultPermission.isSuperPerms()) { 33 | throw new UnsupportedOperationException("Invalid function"); 34 | } 35 | var slash = split(getOptionValue(), '/', true); 36 | var world = slash.size() > 1 ? slash.get(0) : null; 37 | var permission = slash.size() > 1 ? slash.get(1) : slash.get(0); 38 | vaultPermission.playerRemove(world, getSBPlayer().toPlayer(), permission); 39 | return Result.SUCCESS; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/selector/split/SplitType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.selector.split; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | /** 21 | * ScriptBlockPlus SplitType クラス 22 | * @author yuttyann44581 23 | */ 24 | public interface SplitType { 25 | 26 | /** 27 | * 値を取得します。 28 | * @param argument - 引数 29 | * @return {@link String} - 値 30 | */ 31 | @NotNull 32 | public String getValue(@NotNull String argument); 33 | 34 | /** 35 | * 引数が一致するのかどうか。 36 | * @param argument - 引数 37 | * @return {@code boolean} - 一致する場合は{@code true} 38 | */ 39 | public boolean match(@NotNull String argument); 40 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/selector/split/SplitValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.selector.split; 17 | 18 | import com.github.yuttyann.scriptblockplus.enums.splittype.Argument; 19 | import com.github.yuttyann.scriptblockplus.utils.StringUtils; 20 | 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | /** 24 | * ScriptBlockPlus SplitValue クラス 25 | * @author yuttyann44581 26 | */ 27 | public final class SplitValue { 28 | 29 | private final SplitType type; 30 | private final String value; 31 | 32 | private String cacheValue; 33 | private Boolean cacheInverted; 34 | 35 | /** 36 | * コンストラクタ 37 | * @param argument - 引数 38 | * @param type - 要素(例: {@link Argument}等) 39 | */ 40 | public SplitValue(@NotNull String argument, @NotNull SplitType type) { 41 | if (type.match(argument)) { 42 | this.type = type; 43 | this.value = type.getValue(argument); 44 | } else { 45 | throw new NullPointerException("SplitType[" + argument + "] not found"); 46 | } 47 | } 48 | 49 | /** 50 | * コンストラクタ 51 | * @param argument - 引数 52 | * @param types - 要素の配列(例: {@link Argument}等) 53 | */ 54 | public SplitValue(@NotNull String argument, @NotNull SplitType[] types) { 55 | for (var splitType : types) { 56 | if (splitType.match(argument)) { 57 | this.type = splitType; 58 | this.value = splitType.getValue(argument); 59 | return; 60 | } 61 | } 62 | throw new NullPointerException("SplitType[" + argument + "] not found"); 63 | } 64 | 65 | /** 66 | * {@link SplitType}を取得します。 67 | * @return {@link SplitType} - 引数の種類 68 | */ 69 | @NotNull 70 | public SplitType getType() { 71 | return type; 72 | } 73 | 74 | /** 75 | * 値を取得します。 76 | * @return {@link String} - 値 77 | */ 78 | @NotNull 79 | public String getValue() { 80 | if (cacheValue == null && StringUtils.isNotEmpty(value)) { 81 | cacheValue = isInverted() ? value.substring(1) : value; 82 | } 83 | return cacheValue; 84 | } 85 | 86 | /** 87 | * 否定形なのかどうか。 88 | * @return {@code boolean} - 否定形な場合は{@code true} 89 | */ 90 | public boolean isInverted() { 91 | if (cacheInverted == null && StringUtils.isNotEmpty(value)) { 92 | cacheInverted = value.indexOf("!") == 0; 93 | } 94 | return cacheInverted; 95 | } 96 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/utils/collection/ReuseIterator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.utils.collection; 17 | 18 | import java.util.Collection; 19 | import java.util.Iterator; 20 | import java.util.NoSuchElementException; 21 | import java.util.function.IntFunction; 22 | 23 | import org.jetbrains.annotations.NotNull; 24 | 25 | /** 26 | * ScriptBlockPlus ReuseIterator クラス 27 | *

28 | * 繰り返し検索を行えるようにするイテラトラ 29 | * @param 値の型 30 | * @author yuttyann44581 31 | */ 32 | public class ReuseIterator implements Iterator { 33 | 34 | private final T[] array; 35 | private final int length; 36 | 37 | private int cursor; 38 | private boolean hasNext; 39 | 40 | public ReuseIterator(@NotNull T[] array) { 41 | this.array = array; 42 | this.length = array.length; 43 | hasNext(); 44 | } 45 | 46 | public ReuseIterator(@NotNull Collection collection, @NotNull IntFunction generator) { 47 | this(collection.toArray(generator)); 48 | } 49 | 50 | public void reset() { 51 | this.cursor = 0; 52 | hasNext(); 53 | } 54 | 55 | @Override 56 | public boolean hasNext() { 57 | return hasNext = cursor < length; 58 | } 59 | 60 | @Override 61 | public T next() { 62 | if (!hasNext) { 63 | throw new NoSuchElementException(); 64 | } 65 | return array[cursor++]; 66 | } 67 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/utils/kyori/KyoriGson.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.yuttyann.scriptblockplus.utils.kyori; 3 | 4 | import java.io.IOException; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.google.gson.Gson; 9 | import com.google.gson.JsonElement; 10 | import com.google.gson.TypeAdapter; 11 | 12 | import net.kyori.adventure.text.Component; 13 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; 14 | import net.kyori.adventure.text.serializer.json.JSONOptions; 15 | 16 | public final class KyoriGson { 17 | 18 | private static final TypeAdapter TYPE_ADAPTER = new Gson().getAdapter(JsonElement.class); 19 | private static final GsonComponentSerializer GSON_SERIALIZER; 20 | 21 | static { 22 | var builder = GsonComponentSerializer.colorDownsamplingGson().toBuilder(); 23 | builder.editOptions(state -> { 24 | state.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, false); 25 | }); 26 | GSON_SERIALIZER = builder.build(); 27 | } 28 | 29 | private KyoriGson() { } 30 | 31 | @NotNull 32 | public static Component fromString(@NotNull String input) { 33 | return GSON_SERIALIZER.deserialize(input); 34 | } 35 | 36 | @NotNull 37 | public static Component fromJsonElement(@NotNull JsonElement input) { 38 | return GSON_SERIALIZER.deserializeFromTree(input); 39 | } 40 | 41 | @NotNull 42 | public static String toJson(@NotNull Component component) { 43 | return GSON_SERIALIZER.serialize(component); 44 | } 45 | 46 | @NotNull 47 | public static JsonElement toJsonElement(@NotNull Component component) { 48 | return GSON_SERIALIZER.serializeToTree(component); 49 | } 50 | 51 | public static boolean isJsonInValid(@NotNull String input) { 52 | return !isJsonValid(input); 53 | } 54 | 55 | public static boolean isJsonValid(@NotNull String input) { 56 | if (input.isEmpty()) { 57 | return false; 58 | } 59 | var ch = input.charAt(0); 60 | if (ch == '{' || ch == '[') { 61 | try { 62 | TYPE_ADAPTER.fromJson(input); 63 | return true; 64 | } catch (IOException ignored) { } 65 | } 66 | return false; 67 | } 68 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/utils/kyori/KyoriLegacy.java: -------------------------------------------------------------------------------- 1 | package com.github.yuttyann.scriptblockplus.utils.kyori; 2 | 3 | import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.*; 4 | 5 | import java.util.List; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 10 | import net.kyori.adventure.text.Component; 11 | import net.kyori.adventure.text.TextComponent; 12 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 13 | 14 | public final class KyoriLegacy { 15 | 16 | @NotNull 17 | public static LegacyComponentSerializer of(char legacyCharacter) { 18 | return legacy(legacyCharacter); 19 | } 20 | 21 | @NotNull 22 | public static TextComponent fromString(@NotNull String input) { 23 | return legacySection().deserialize(input); 24 | } 25 | 26 | @NotNull 27 | public static List fromStringList(@NotNull List inputs) { 28 | var components = new ObjectArrayList(inputs.size()); 29 | for (var legacyText : inputs) { 30 | components.add(fromString(legacyText)); 31 | } 32 | return components; 33 | } 34 | 35 | @NotNull 36 | public static String toString(@NotNull Component component) { 37 | return legacySection().serialize(component); 38 | } 39 | 40 | @NotNull 41 | public static String toString(@NotNull Component... components) { 42 | var builder = new StringBuilder(); 43 | for (var component : components) { 44 | builder.append(toString(component)); 45 | } 46 | return builder.toString(); 47 | } 48 | 49 | @NotNull 50 | public static List toStringList(@NotNull Component... components) { 51 | var legacyList = new ObjectArrayList(components.length); 52 | for (var component : components) { 53 | legacyList.add(toString(component)); 54 | } 55 | return legacyList; 56 | } 57 | 58 | @NotNull 59 | public static List toStringList(@NotNull List components) { 60 | var legacyList = new ObjectArrayList(components.size()); 61 | for (var component : components) { 62 | legacyList.add(toString(component)); 63 | } 64 | return legacyList; 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/utils/raytrace/RayResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.utils.raytrace; 17 | 18 | import org.bukkit.block.Block; 19 | import org.bukkit.block.BlockFace; 20 | import org.jetbrains.annotations.NotNull; 21 | import org.jetbrains.annotations.Nullable; 22 | 23 | /** 24 | * ScriptBlockPlus RayResult クラス 25 | * @author yuttyann44581 26 | */ 27 | public final class RayResult { 28 | 29 | private Block block; 30 | private BlockFace blockFace; 31 | 32 | /** 33 | * コンストラクタ 34 | * @param block - ブロック 35 | * @param blockFace - ブロックの側面 36 | */ 37 | public RayResult(@NotNull Block block, @Nullable BlockFace blockFace) { 38 | this.block = block; 39 | this.blockFace = blockFace == null ? BlockFace.SOUTH : blockFace; 40 | } 41 | 42 | /** 43 | * ブロックを取得します。 44 | * @return {@link Block} - ブロック 45 | */ 46 | @NotNull 47 | public Block getHitBlock() { 48 | return block; 49 | } 50 | 51 | /** 52 | * 側面のブロックを取得します。 53 | * @return {@link Block} - 側面のブロック 54 | */ 55 | @NotNull 56 | public Block getRelative() { 57 | return block.getRelative(blockFace); 58 | } 59 | 60 | /** 61 | * ブロックの側面を取得します。 62 | * @return {@link BlockFace} - ブロックの側面 63 | */ 64 | @NotNull 65 | public BlockFace getHitBlockFace() { 66 | return blockFace == null ? BlockFace.SELF : blockFace; 67 | } 68 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/utils/reflect/Reflection.java: -------------------------------------------------------------------------------- 1 | package com.github.yuttyann.scriptblockplus.utils.reflect; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import com.github.yuttyann.scriptblockplus.utils.reflect.matcher.ConstructorMatcher; 6 | import com.github.yuttyann.scriptblockplus.utils.reflect.matcher.FieldMatcher; 7 | import com.github.yuttyann.scriptblockplus.utils.reflect.matcher.MethodMatcher; 8 | import com.github.yuttyann.scriptblockplus.utils.reflect.matcher.ReflectionMatcher.ConstructorStore; 9 | import com.github.yuttyann.scriptblockplus.utils.reflect.matcher.ReflectionMatcher.FieldStore; 10 | import com.github.yuttyann.scriptblockplus.utils.reflect.matcher.ReflectionMatcher.MethodStore; 11 | 12 | public final class Reflection { 13 | 14 | private Reflection() { } 15 | 16 | @NotNull 17 | public static FieldMatcher field(@NotNull Class targetType) { 18 | return FieldMatcher.of(targetType); 19 | } 20 | 21 | @NotNull 22 | public static FieldStore fields() { 23 | return FieldMatcher.store(); 24 | } 25 | 26 | @NotNull 27 | public static MethodMatcher method(@NotNull Class targetType) { 28 | return MethodMatcher.of(targetType); 29 | } 30 | 31 | @NotNull 32 | public static MethodStore methods() { 33 | return MethodMatcher.store(); 34 | } 35 | 36 | @NotNull 37 | public static ConstructorMatcher construct(@NotNull Class targetType) { 38 | return ConstructorMatcher.of(targetType); 39 | } 40 | 41 | @NotNull 42 | public static ConstructorStore constructs() { 43 | return ConstructorMatcher.store(); 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/utils/unmodifiable/UnmodifiableBlockCoords.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.utils.unmodifiable; 17 | 18 | import com.github.yuttyann.scriptblockplus.BlockCoords; 19 | 20 | import org.bukkit.Location; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | /** 24 | * ScriptBlockPlus UnmodifiableBlockCoords クラス 25 | *

26 | * 座標が変更されることが無いため、{@link UnmodifiableBlockCoords#toLocation}の情報はキャッシュされる。 27 | * @author yuttyann44581 28 | */ 29 | public final class UnmodifiableBlockCoords extends BlockCoords { 30 | 31 | private Location location; 32 | 33 | public UnmodifiableBlockCoords(@NotNull BlockCoords blockCoords) { 34 | super(blockCoords.getWorld(), blockCoords.getX(), blockCoords.getY(), blockCoords.getZ()); 35 | } 36 | 37 | @Override 38 | public void setX(int x) { 39 | throw new UnsupportedOperationException(this.getClass().getName()); 40 | } 41 | 42 | @Override 43 | public void setY(int y) { 44 | throw new UnsupportedOperationException(this.getClass().getName()); 45 | } 46 | 47 | @Override 48 | public void setZ(int z) { 49 | throw new UnsupportedOperationException(this.getClass().getName()); 50 | } 51 | 52 | @Override 53 | @NotNull 54 | public BlockCoords add(int x, int y, int z) { 55 | throw new UnsupportedOperationException(this.getClass().getName()); 56 | } 57 | 58 | @Override 59 | @NotNull 60 | public BlockCoords subtract(int x, int y, int z) { 61 | throw new UnsupportedOperationException(this.getClass().getName()); 62 | } 63 | 64 | @Override 65 | @NotNull 66 | public Location toLocation() { 67 | return location == null ? location = super.toLocation() : location; 68 | } 69 | } -------------------------------------------------------------------------------- /src/main/java/com/github/yuttyann/scriptblockplus/utils/unmodifiable/UnmodifiableItemStack.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ScriptBlockPlus - Allow you to add script to any blocks. 3 | * Copyright (C) 2021 yuttyann44581 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 10 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * See the GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with this program. 14 | * If not, see . 15 | */ 16 | package com.github.yuttyann.scriptblockplus.utils.unmodifiable; 17 | 18 | import org.bukkit.Material; 19 | import org.bukkit.enchantments.Enchantment; 20 | import org.bukkit.inventory.ItemStack; 21 | import org.bukkit.inventory.meta.ItemMeta; 22 | import org.bukkit.material.MaterialData; 23 | import org.jetbrains.annotations.NotNull; 24 | import org.jetbrains.annotations.Nullable; 25 | import java.util.Map; 26 | 27 | /** 28 | * ScriptBlockPlus UnmodifiableItemStack クラス 29 | * @author yuttyann44581 30 | */ 31 | @SuppressWarnings("deprecation") 32 | public final class UnmodifiableItemStack extends ItemStack { 33 | 34 | public UnmodifiableItemStack(@NotNull ItemStack item) { 35 | super(item); 36 | } 37 | 38 | @Override 39 | public void setType(@NotNull Material type) { 40 | throw new UnsupportedOperationException(this.getClass().getName()); 41 | } 42 | 43 | @Override 44 | public void setAmount(int amount) { 45 | throw new UnsupportedOperationException(this.getClass().getName()); 46 | } 47 | 48 | @Override 49 | public void setData(@Nullable MaterialData data) { 50 | throw new UnsupportedOperationException(this.getClass().getName()); 51 | } 52 | 53 | @Override 54 | @Deprecated 55 | public void setDurability(short durability) { 56 | throw new UnsupportedOperationException(this.getClass().getName()); 57 | } 58 | 59 | @Override 60 | public void addEnchantment(@NotNull Enchantment ench, int level) { 61 | throw new UnsupportedOperationException(this.getClass().getName()); 62 | } 63 | 64 | @Override 65 | public void addEnchantments(@NotNull Map enchantments) { 66 | throw new UnsupportedOperationException(this.getClass().getName()); 67 | } 68 | 69 | @Override 70 | public void addUnsafeEnchantment(@NotNull Enchantment ench, int level) { 71 | throw new UnsupportedOperationException(this.getClass().getName()); 72 | } 73 | 74 | @Override 75 | public void addUnsafeEnchantments(@NotNull Map enchantments) { 76 | throw new UnsupportedOperationException(this.getClass().getName()); 77 | } 78 | 79 | @Override 80 | public int removeEnchantment(@NotNull Enchantment ench) { 81 | throw new UnsupportedOperationException(this.getClass().getName()); 82 | } 83 | 84 | @Override 85 | public boolean setItemMeta(@Nullable ItemMeta meta) { 86 | throw new UnsupportedOperationException(this.getClass().getName()); 87 | } 88 | } -------------------------------------------------------------------------------- /src/main/resources/config/en.yml: -------------------------------------------------------------------------------- 1 | # ScriptBlockPlus v${project.version} Lang # 2 | 3 | 4 | ## ===== Json ===== ## 5 | # [true -> Enable | false -> Disable] 6 | # Cache all files on server startup or reload. 7 | # It can run smoothly, but may consume a lot of memory. 8 | CacheAllJson: true 9 | 10 | # Sets the upper limit of the number of elements allowed to format JSON. 11 | # By setting an upper limit, you can expect to reduce the capacity and speed up the process. 12 | FormatLimit: 10000 13 | 14 | ## ===== Sort Scripts ===== ## 15 | # [true -> Enable | false -> Disable] 16 | # Sort the options in the best order. 17 | SortScripts: true 18 | 19 | ## ===== Console Log ===== ## 20 | # [true -> Enable | false -> Disable] 21 | # The initial "console" of the language file is the target. 22 | # You can display detailed messages on the console. 23 | ConsoleLog: false 24 | 25 | ## ===== Option Help ===== ## 26 | # [true -> Enable | false -> Disable] 27 | # Displays option help when tab completion is performed. 28 | OptionHelp: true 29 | 30 | ## ===== Option Permission ===== ## 31 | # [true -> Enable | false -> Disable] 32 | # Requests permission when executing the option. 33 | OptionPermission: false 34 | 35 | ## ===== Arm Actions ===== ## 36 | # [true -> Enable | false -> Disable] 37 | # Enables / disables the left and right clicks. 38 | Actions: 39 | # LeftClick 40 | InteractLeft: true 41 | # RightClick 42 | InteractRight: true -------------------------------------------------------------------------------- /src/main/resources/config/ja.yml: -------------------------------------------------------------------------------- 1 | # ScriptBlockPlus v${project.version} Config # 2 | 3 | 4 | ## ===== Json ===== ## 5 | # [true -> 有効 | false -> 無効] 6 | # リロード、サーバー起動時に全ファイルをキャッシュします。 7 | # スムーズな動作が可能ですが、メモリを多く消費する可能性があります。 8 | CacheAllJson: true 9 | 10 | # JSONの整形を許可する要素数の上限を設定します。 11 | # 上限を設定することで、容量の削減や処理速度の短縮が期待できます。 12 | FormatLimit: 10000 13 | 14 | ## ===== スクリプトの並び替え ===== ## 15 | # [true -> 有効 | false -> 無効] 16 | # スクリプト実行時に推奨される順番通りにオプションを実行するかどうか。 17 | # 設定されている優先順にオプションを並び替えて最適な順番で実行します。 18 | SortScripts: true 19 | 20 | ## ===== コンソールログ ===== ## 21 | # [true -> 有効 | false -> 無効] 22 | # 言語ファイルの頭文字"console"が対象です。 23 | # コンソールに操作メッセージ等を表示させることができます。 24 | ConsoleLog: false 25 | 26 | ## ===== オプションヘルプ ===== ## 27 | # [true -> 有効 | false -> 無効] 28 | # タブ補完を行った際に、オプションのヘルプを表示するかどうか。 29 | OptionHelp: true 30 | 31 | ## ===== オプション実行権限 ===== ## 32 | # [true -> 有効 | false -> 無効] 33 | # オプションを実行時に権限をチェックするかどうか。 34 | OptionPermission: false 35 | 36 | ## ===== スクリプトの実行 ===== ## 37 | # [true -> 有効 | false -> 無効] 38 | # "左"または"右"クリックからのスクリプトの実行を無効化するかどうか。 39 | Actions: 40 | # 左クリックの設定 41 | InteractLeft: true 42 | # 右クリックの設定 43 | InteractRight: true -------------------------------------------------------------------------------- /src/main/resources/config/zh.yml: -------------------------------------------------------------------------------- 1 | # ScriptBlockPlus v${project.version} Config # 2 | 3 | 4 | ## ===== Json ===== ## 5 | # [true -> 真 | false -> 假] 6 | # 是否在服务器启动时预先缓存所有Json 7 | # 可以大大增加流畅性但是会消耗大量内存 8 | CacheAllJson: true 9 | 10 | # 为Json中可被格式化的元素数量设置一个上限 11 | # 通过设置一个上限 你可以期望减少容量 加快进程 12 | FormatLimit: 10000 13 | 14 | ## ===== 排序脚本 ===== ## 15 | # [true -> 真 | false -> 假] 16 | # 按照推荐的脚本执行顺序运行选项 17 | SortScripts: true 18 | 19 | ## ===== 控制台输出 ===== ## 20 | # [true -> 真 | false -> 假] 21 | # 在控制台记录脚本方块触发 情况 22 | ConsoleLog: false 23 | 24 | ## ===== Tab内容补全设定 ===== ## 25 | # [true -> 真 | false -> 假] 26 | # タブ補完を行った際に、オプションのヘルプを表示するかどうか。 27 | OptionHelp: true 28 | 29 | ## ===== 检查权限 ===== ## 30 | # [true -> 真 | false -> 假] 31 | # 当玩家输入指令并按Tab键时是否显示可选指令内容 32 | OptionPermission: false 33 | 34 | ## ===== 点击脚本方块设定 ===== ## 35 | # [true -> 真 | false -> 假] 36 | # 左键点击和右键点击是否都可以? 37 | Actions: 38 | InteractLeft: true 39 | InteractRight: true --------------------------------------------------------------------------------