├── .editorconfig ├── lib ├── NoCheatPlus.jar └── Essentials-2.13-SNAPSHOT.jar ├── .gitignore ├── src ├── main │ ├── java │ │ └── de │ │ │ └── czymm │ │ │ └── serversigns │ │ │ ├── utils │ │ │ ├── MaterialUtils.java │ │ │ ├── formatter │ │ │ │ ├── BasicMessageFormatter.java │ │ │ │ ├── PlaceholderMessageFormatter.java │ │ │ │ └── MessageFormatter.java │ │ │ ├── CurrentTime.java │ │ │ ├── BlockUtils.java │ │ │ └── Version.java │ │ │ ├── config │ │ │ ├── IServerSignsConfig.java │ │ │ └── ConfigLoadingException.java │ │ │ ├── signs │ │ │ └── CancelMode.java │ │ │ ├── taskmanager │ │ │ ├── tasks │ │ │ │ ├── ServerActionTaskType.java │ │ │ │ ├── TaskStatus.java │ │ │ │ ├── PermissionGrantPlayerTaskType.java │ │ │ │ ├── TaskType.java │ │ │ │ ├── PermissionRemovePlayerTaskType.java │ │ │ │ ├── PlayerActionTaskType.java │ │ │ │ ├── ServerActionTaskLoader.java │ │ │ │ ├── PermissionGrantPlayerTaskLoader.java │ │ │ │ ├── PlayerActionTaskLoader.java │ │ │ │ ├── ServerActionTask.java │ │ │ │ ├── PermissionGrantPlayerTask.java │ │ │ │ ├── PlayerTask.java │ │ │ │ └── PermissionRemovePlayerTaskLoader.java │ │ │ ├── datastorage │ │ │ │ ├── PersistAction.java │ │ │ │ ├── IDataStorageHandler.java │ │ │ │ ├── ISQLiteTaskLoader.java │ │ │ │ ├── ISQLiteTaskSaver.java │ │ │ │ ├── ISQLiteTaskDeleter.java │ │ │ │ ├── IDataStorageAccessor.java │ │ │ │ ├── PersistTask.java │ │ │ │ ├── TaskDeleter.java │ │ │ │ ├── PlayerTaskDeleter.java │ │ │ │ ├── TaskSaver.java │ │ │ │ ├── PersistTaskExecutor.java │ │ │ │ ├── PlayerTaskSaver.java │ │ │ │ └── SQLiteDataStorageHandler.java │ │ │ ├── ITaskExecutor.java │ │ │ └── QueueConsumer.java │ │ │ ├── persist │ │ │ ├── mapping │ │ │ │ ├── ISmartPersistenceMapper.java │ │ │ │ ├── IPersistenceMapper.java │ │ │ │ ├── MappingException.java │ │ │ │ ├── DefaultPersistenceMapper.java │ │ │ │ ├── ColouredStringMapper.java │ │ │ │ ├── PlayerUniqueIdMapper.java │ │ │ │ ├── CancelEnumMapper.java │ │ │ │ ├── PlayerActionTaskTypeEnumMapper.java │ │ │ │ ├── ServerActionTaskTypeEnumMapper.java │ │ │ │ ├── StringLongHashMapper.java │ │ │ │ ├── ItemSearchCriteriaMapper.java │ │ │ │ ├── ItemStackListMapper.java │ │ │ │ └── BlocksMapper.java │ │ │ ├── PersistenceException.java │ │ │ └── PersistenceEntry.java │ │ │ ├── parsing │ │ │ ├── CommandParseException.java │ │ │ ├── AliasSet.java │ │ │ ├── operators │ │ │ │ ├── IsOpOperator.java │ │ │ │ ├── HasPermOperator.java │ │ │ │ ├── LoopIsOperator.java │ │ │ │ ├── UsesTallyIsOperator.java │ │ │ │ ├── IsAfterOperator.java │ │ │ │ ├── IsBeforeOperator.java │ │ │ │ ├── RandomOperator.java │ │ │ │ ├── HasBalanceOperator.java │ │ │ │ └── OnlinePlayersOperator.java │ │ │ ├── CommandType.java │ │ │ └── command │ │ │ │ └── ReturnServerSignCommand.java │ │ │ ├── translations │ │ │ └── NoDefaultException.java │ │ │ ├── itemdata │ │ │ ├── IItemData.java │ │ │ ├── BasicItemData.java │ │ │ ├── DataException.java │ │ │ ├── ItemData.java │ │ │ ├── ItemName.java │ │ │ ├── ItemLore.java │ │ │ ├── ItemAmount.java │ │ │ ├── ItemDamage.java │ │ │ ├── ItemPart.java │ │ │ ├── ItemType.java │ │ │ └── ItemSearchCriteria.java │ │ │ ├── commands │ │ │ ├── core │ │ │ │ └── CommandException.java │ │ │ ├── SubCommandCreate.java │ │ │ ├── SubCommandRemove.java │ │ │ ├── SubCommandResetCooldown.java │ │ │ ├── SubCommandReloadSigns.java │ │ │ ├── SubCommandAdd.java │ │ │ ├── SubCommandVoid.java │ │ │ ├── SubCommandSilent.java │ │ │ ├── SubCommandXP.java │ │ │ ├── SubCommandSetPrice.java │ │ │ ├── SubCommandSelect.java │ │ │ ├── SubCommandReloadConfig.java │ │ │ ├── SubCommandEdit.java │ │ │ ├── SubCommandResetAllCooldowns.java │ │ │ ├── SubCommandInsert.java │ │ │ ├── SubCommandSetLoops.java │ │ │ ├── SubCommandSetUses.java │ │ │ ├── SubCommandSetCooldown.java │ │ │ ├── SubCommandCancel.java │ │ │ ├── SubCommandConfirmation.java │ │ │ ├── SubCommandReload.java │ │ │ ├── SubCommandSetGlobalCooldown.java │ │ │ ├── SubCommandCancelPermission.java │ │ │ ├── SubCommandHeldItemCriteria.java │ │ │ ├── SubCommandPriceItemCriteria.java │ │ │ ├── SubCommandCopy.java │ │ │ ├── SubCommandDev.java │ │ │ ├── SubCommandList.java │ │ │ ├── SubCommandImport.java │ │ │ └── SubCommandGrantPermission.java │ │ │ ├── hooks │ │ │ ├── PlaceholderAPIHook.java │ │ │ ├── EssentialsHook.java │ │ │ ├── HookWrapper.java │ │ │ └── VaultHook.java │ │ │ ├── meta │ │ │ └── SVSMetaKey.java │ │ │ └── legacy │ │ │ └── LanguageYmlConverter.java │ └── resources │ │ └── plugin.yml └── test │ └── java │ └── de │ └── czymm │ └── serversigns │ └── taskmanager │ └── QueueConsumerTest.java └── .github └── workflows ├── build.yml └── release.yml /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | indent_size = 4 4 | -------------------------------------------------------------------------------- /lib/NoCheatPlus.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serversigns/ServerSigns/HEAD/lib/NoCheatPlus.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | ServerSigns.iml 4 | .classpath 5 | .settings 6 | .project 7 | .metals 8 | .bloop 9 | -------------------------------------------------------------------------------- /lib/Essentials-2.13-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serversigns/ServerSigns/HEAD/lib/Essentials-2.13-SNAPSHOT.jar -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/utils/MaterialUtils.java: -------------------------------------------------------------------------------- 1 | package de.czymm.serversigns.utils; 2 | 3 | import org.bukkit.Material; 4 | 5 | import java.util.EnumSet; 6 | 7 | public class MaterialUtils { 8 | private MaterialUtils() {} 9 | 10 | public static EnumSet getMaterials(String... materials) { 11 | EnumSet enumSet = EnumSet.noneOf(Material.class); 12 | 13 | for(int i = 0; i < materials.length; i++) { 14 | Material mat = Material.getMaterial(materials[i]); 15 | if (mat != null) 16 | enumSet.add(mat); 17 | } 18 | 19 | return enumSet; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/config/IServerSignsConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.config; 19 | 20 | public interface IServerSignsConfig { 21 | int getVersion(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/signs/CancelMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.signs; 19 | 20 | public enum CancelMode { 21 | ALWAYS, 22 | NEVER, 23 | SUCCESS_ONLY, 24 | FAIL_ONLY 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/ServerActionTaskType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | public enum ServerActionTaskType { 21 | COMMAND, 22 | BROADCAST 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/TaskStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | public enum TaskStatus { 21 | ERROR, 22 | SUCCESS, 23 | PLAYER_NOT_ONLINE 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/PersistAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | public enum PersistAction { 21 | SAVE, 22 | DELETE, 23 | STOP 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PermissionGrantPlayerTaskType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | public enum PermissionGrantPlayerTaskType { 21 | PERMISSION_GRANT 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/TaskType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | public enum TaskType { 21 | SERVER, 22 | PLAYER, 23 | PERMISSION_GRANT, 24 | PERMISSION_REMOVE 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/ISmartPersistenceMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | public interface ISmartPersistenceMapper extends IPersistenceMapper { 21 | void setHostId(String id); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PermissionRemovePlayerTaskType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | public enum PermissionRemovePlayerTaskType { 21 | PERMISSION_GRANT_REMOVE, 22 | PERMISSION_REMOVE 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/ITaskExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager; 19 | 20 | import java.util.List; 21 | 22 | public interface ITaskExecutor { 23 | void runTasks(List tasks); 24 | 25 | void runTask(E task); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/CommandParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing; 19 | 20 | public class CommandParseException extends Exception { 21 | 22 | public CommandParseException(String message) { 23 | super(message); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PlayerActionTaskType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | public enum PlayerActionTaskType { 21 | CHAT, 22 | MESSAGE, 23 | COMMAND, 24 | OP_COMMAND, 25 | BLANK_MESSAGE, 26 | SERVER_COMMAND, 27 | ADD_GROUP, 28 | DEL_GROUP, 29 | CANCEL_TASKS 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/IDataStorageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | public interface IDataStorageHandler { 21 | void init() throws Exception; 22 | 23 | IDataStorageAccessor newDataStorageAccessor() throws Exception; 24 | 25 | void addTask(PersistTask task); 26 | 27 | void close(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/PersistenceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist; 19 | 20 | public class PersistenceException extends Exception { 21 | public PersistenceException(String message) { 22 | super(message); 23 | } 24 | 25 | public PersistenceException(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/config/ConfigLoadingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.config; 19 | 20 | public class ConfigLoadingException extends Exception { 21 | public ConfigLoadingException(String message) { 22 | super(message); 23 | } 24 | 25 | public ConfigLoadingException(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/translations/NoDefaultException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.translations; 19 | 20 | public class NoDefaultException extends Exception { 21 | 22 | public NoDefaultException(String message) { 23 | super(message); 24 | } 25 | 26 | public NoDefaultException(String message, Throwable thrown) { 27 | super(message, thrown); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/IItemData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.inventory.ItemStack; 21 | import org.bukkit.inventory.meta.ItemMeta; 22 | 23 | public interface IItemData { 24 | ItemStack applyValue(ItemStack item, String value) throws DataException; 25 | 26 | ItemMeta applyMetaValue(ItemMeta item, String value) throws DataException; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/IPersistenceMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import org.bukkit.configuration.MemorySection; 21 | 22 | public interface IPersistenceMapper { 23 | void setMemorySection(MemorySection memorySection); 24 | 25 | E getValue(String path) throws MappingException; 26 | 27 | void setValue(String path, E value); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/ISQLiteTaskLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | 22 | import java.sql.ResultSet; 23 | import java.sql.SQLException; 24 | import java.util.Map; 25 | 26 | public interface ISQLiteTaskLoader { 27 | T getTaskFromCurrentRow(ResultSet resultSet, Map loadedTasks) throws SQLException; 28 | } 29 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path 3 | 4 | name: Build ServerSigns plugin 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | contents: read 17 | packages: write 18 | steps: 19 | - uses: actions/checkout@v4 20 | - name: Set up JDK 11 21 | uses: actions/setup-java@v4 22 | with: 23 | java-version: '11' 24 | distribution: 'temurin' 25 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 26 | settings-path: ${{ github.workspace }} # location for the settings.xml file 27 | - name: Build with Maven 28 | run: mvn clean package -DskipTests=true -DgeneratePom=false -DbuildNumber=-${{ github.run_number }} 29 | - name: Upload artifacts 30 | uses: actions/upload-artifact@v4 31 | with: 32 | name: ServerSigns-${{ github.run_number }} 33 | path: target/ServerSigns-*.jar 34 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/ISQLiteTaskSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | 22 | import java.sql.Connection; 23 | import java.sql.SQLException; 24 | import java.util.List; 25 | 26 | public interface ISQLiteTaskSaver { 27 | void saveTask(Connection connection, TaskManagerTask task, List closeChain) throws SQLException; 28 | 29 | void close() throws SQLException; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/MappingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | public class MappingException extends Exception { 21 | 22 | public enum ExceptionType { 23 | COMMANDS,; 24 | } 25 | 26 | private ExceptionType type; 27 | 28 | public MappingException(String message, ExceptionType type) { 29 | super(message); 30 | this.type = type; 31 | } 32 | 33 | public ExceptionType getType() { 34 | return type; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/ISQLiteTaskDeleter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | 22 | import java.sql.Connection; 23 | import java.sql.SQLException; 24 | import java.util.List; 25 | 26 | public interface ISQLiteTaskDeleter { 27 | void deleteTask(Connection connection, TaskManagerTask task, List closeChain) throws SQLException; 28 | 29 | void close() throws SQLException; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/BasicItemData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.Material; 21 | 22 | public class BasicItemData { 23 | private Material material; 24 | private short durability; 25 | 26 | public BasicItemData(Material type, short damage) { 27 | this.material = type; 28 | this.durability = damage; 29 | } 30 | 31 | public Material getType() { 32 | return material; 33 | } 34 | 35 | public short getDurability() { 36 | return durability; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path 3 | 4 | name: Release ServerSigns plugin 5 | 6 | on: 7 | push: 8 | tags: [ v* ] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | permissions: 14 | contents: write 15 | packages: write 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Set up JDK 11 19 | uses: actions/setup-java@v4 20 | with: 21 | java-version: '11' 22 | distribution: 'temurin' 23 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 24 | settings-path: ${{ github.workspace }} # location for the settings.xml file 25 | - name: Build with Maven 26 | run: mvn clean package -DskipTests=true -DgeneratePom=false 27 | - name: Upload artifacts 28 | uses: actions/upload-artifact@v4 29 | with: 30 | name: ServerSigns 31 | path: target/ServerSigns-*.jar 32 | - name: Release 33 | uses: softprops/action-gh-release@v2 34 | if: startsWith(github.ref, 'refs/tags/') 35 | with: 36 | draft: true 37 | files: target/ServerSigns-*.jar 38 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/utils/formatter/BasicMessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package de.czymm.serversigns.utils.formatter; 18 | 19 | import org.bukkit.command.CommandSender; 20 | 21 | public class BasicMessageFormatter extends MessageFormatter { 22 | /** 23 | * Format a message to send to a player 24 | * 25 | * @param player Player to use for format 26 | * @param message Message to format 27 | * @return Formatted message 28 | */ 29 | @Override 30 | public String format(final CommandSender player, final String message) { 31 | return MessageFormatter.toColor(message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/core/CommandException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands.core; 19 | 20 | public class CommandException extends Exception { 21 | public CommandException(String message) { 22 | super(message.length() > 1 ? (message.charAt(0) == '\u00A7' ? message : (message.charAt(0) == '&' ? message : "\u00A74Error: \u00A7f")) : ""); 23 | } 24 | 25 | public CommandException(String message, Throwable throwable) { 26 | super(message.length() > 1 ? (message.charAt(0) == '\u00A7' ? message : (message.charAt(0) == '&' ? message : "\u00A74Error: \u00A7f")) : "", throwable); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/IDataStorageAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 22 | 23 | import java.util.Collection; 24 | 25 | public interface IDataStorageAccessor extends AutoCloseable { 26 | void prepareDataStructure() throws Exception; 27 | 28 | Collection loadTasks(ServerSignsPlugin plugin) throws Exception; 29 | 30 | void saveTask(TaskManagerTask task) throws Exception; 31 | 32 | void deleteTask(TaskManagerTask task) throws Exception; 33 | } -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/hooks/PlaceholderAPIHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.hooks; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | 22 | import org.bukkit.Bukkit; 23 | import org.bukkit.plugin.Plugin; 24 | 25 | public class PlaceholderAPIHook { 26 | 27 | protected ServerSignsPlugin pl; 28 | 29 | public PlaceholderAPIHook(ServerSignsPlugin plugin) throws Exception { 30 | pl = plugin; 31 | 32 | final Plugin placeholderApi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI"); 33 | if (placeholderApi == null || !placeholderApi.isEnabled()) { 34 | throw new Exception(); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/meta/SVSMetaKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.meta; 19 | 20 | public enum SVSMetaKey { 21 | ADD, 22 | CANCEL, 23 | CONFIRMATION, 24 | COOLDOWN_RESET, 25 | COPY, 26 | CREATE, 27 | EDIT, 28 | INSERT, 29 | LIST, 30 | GRANT, 31 | PRICE_ITEM, 32 | PRICE_ITEM_CRITERIA, 33 | REMOVE, 34 | SET_COOLDOWN, 35 | SET_GLOBAL_COOLDOWN, 36 | PERMISSION, 37 | PRICE, 38 | XP, 39 | YES, 40 | LOOP, 41 | HOLDING, 42 | HELD_ITEM_CRITERIA, 43 | LONG, 44 | USES, 45 | CANCEL_PERMISSION, 46 | SILENT, 47 | SELECT, 48 | OPTION, 49 | TIME_LIMIT, 50 | IMPORT 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/PersistTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | 22 | public class PersistTask { 23 | private final PersistAction persistAction; 24 | private final TaskManagerTask task; 25 | 26 | public PersistTask(PersistAction persistAction, TaskManagerTask task) { 27 | this.persistAction = persistAction; 28 | this.task = task; 29 | } 30 | 31 | public PersistAction getPersistAction() { 32 | return persistAction; 33 | } 34 | 35 | public TaskManagerTask getTask() { 36 | return task; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/AliasSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing; 19 | 20 | import java.util.Arrays; 21 | import java.util.Collection; 22 | import java.util.HashSet; 23 | 24 | public class AliasSet extends HashSet { 25 | 26 | public AliasSet(String... aliases) { 27 | super(Arrays.asList(aliases)); 28 | } 29 | 30 | public AliasSet(Collection aliases) { 31 | super(aliases); 32 | } 33 | 34 | public boolean matches(String input) { 35 | for (String next : this) { 36 | if (next.equalsIgnoreCase(input)) { 37 | return true; 38 | } 39 | } 40 | return false; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/DefaultPersistenceMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import org.bukkit.configuration.MemorySection; 21 | 22 | public class DefaultPersistenceMapper implements IPersistenceMapper { 23 | private MemorySection memorySection; 24 | 25 | @Override 26 | public void setMemorySection(MemorySection memorySection) { 27 | this.memorySection = memorySection; 28 | } 29 | 30 | @Override 31 | public Object getValue(String path) { 32 | return memorySection.get(path); 33 | } 34 | 35 | @Override 36 | public void setValue(String path, Object value) { 37 | memorySection.set(path, value); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/PersistenceEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist; 19 | 20 | import de.czymm.serversigns.persist.mapping.DefaultPersistenceMapper; 21 | import de.czymm.serversigns.persist.mapping.IPersistenceMapper; 22 | 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | @Target(ElementType.FIELD) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | public @interface PersistenceEntry { 31 | Class configMapper() default DefaultPersistenceMapper.class; 32 | 33 | String configPath() default ""; 34 | 35 | String[] comments() default {}; 36 | } -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/utils/CurrentTime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.utils; 19 | 20 | public class CurrentTime { 21 | private static ITimeProvider timeProvider = new SystemClockTimeProvider(); 22 | 23 | public static long get() { 24 | return timeProvider.getTime(); 25 | } 26 | 27 | public static void setTimeProvider(ITimeProvider timeProvider) { 28 | CurrentTime.timeProvider = timeProvider; 29 | } 30 | 31 | public interface ITimeProvider { 32 | long getTime(); 33 | } 34 | 35 | private static class SystemClockTimeProvider implements ITimeProvider { 36 | @Override 37 | public long getTime() { 38 | return System.currentTimeMillis(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/DataException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | public class DataException extends Exception { 21 | private static final long serialVersionUID = -9036202694165168984L; 22 | protected static final String DEFAULT_MESSAGE = "Invalid value passed to ItemData parser!"; 23 | 24 | public DataException() { 25 | super(DEFAULT_MESSAGE); 26 | } 27 | 28 | public DataException(final Throwable throwable) { 29 | super(DEFAULT_MESSAGE, throwable); 30 | } 31 | 32 | public DataException(final String message) { 33 | super(message); 34 | } 35 | 36 | public DataException(final String message, final Throwable throwable) { 37 | super(message, throwable); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/ColouredStringMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import de.czymm.serversigns.utils.StringUtils; 21 | import org.bukkit.configuration.MemorySection; 22 | 23 | public class ColouredStringMapper implements IPersistenceMapper { 24 | private MemorySection memorySection; 25 | 26 | @Override 27 | public void setMemorySection(MemorySection memorySection) { 28 | this.memorySection = memorySection; 29 | } 30 | 31 | @Override 32 | public String getValue(String path) { 33 | return StringUtils.colour(memorySection.getString(path)); 34 | } 35 | 36 | @Override 37 | public void setValue(String path, String value) { 38 | memorySection.set(path, StringUtils.decolour(value)); 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | public abstract class ItemData implements IItemData { 21 | private ItemPart key; 22 | 23 | public ItemPart getDataKey() { 24 | return key; 25 | } 26 | 27 | private String[] matchPrefixes; 28 | 29 | public String[] getMatcherPrefix() { 30 | return matchPrefixes; 31 | } 32 | 33 | private boolean applyToMeta = false; 34 | 35 | public boolean canApplyToMeta() { 36 | return applyToMeta; 37 | } 38 | 39 | protected void setApplyToMeta(boolean newVal) { 40 | this.applyToMeta = newVal; 41 | } 42 | 43 | public ItemData(ItemPart key, String[] matchPrefixes) { 44 | this.key = key; 45 | this.matchPrefixes = matchPrefixes; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/IsOpOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import org.bukkit.entity.Player; 23 | 24 | public class IsOpOperator extends ConditionalOperator { 25 | 26 | public IsOpOperator() { 27 | super("isOp", false); 28 | } 29 | 30 | @Override 31 | public ParameterValidityResponse checkParameterValidity(String params) { 32 | return new ParameterValidityResponse(true); // Params are irrelevant 33 | } 34 | 35 | @Override 36 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 37 | if (executor == null) { 38 | return true; // Console 39 | } 40 | return executor.isOp(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/utils/formatter/PlaceholderMessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package de.czymm.serversigns.utils.formatter; 18 | 19 | import me.clip.placeholderapi.PlaceholderAPI; 20 | import org.bukkit.command.CommandSender; 21 | import org.bukkit.entity.Player; 22 | 23 | public class PlaceholderMessageFormatter extends MessageFormatter { 24 | /** 25 | * Format a message to send to a player 26 | * 27 | * @param player Player to use for format 28 | * @param message Message to format 29 | * @return Formatted message 30 | */ 31 | @Override 32 | public String format(final CommandSender player, final String message) { 33 | final String msg = MessageFormatter.toColor(message); 34 | if (player instanceof Player) { 35 | return PlaceholderAPI.setPlaceholders((Player)player, msg); 36 | } 37 | return msg; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/ServerActionTaskLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | import de.czymm.serversigns.taskmanager.datastorage.ISQLiteTaskLoader; 22 | 23 | import java.sql.ResultSet; 24 | import java.sql.SQLException; 25 | import java.util.Map; 26 | 27 | public class ServerActionTaskLoader implements ISQLiteTaskLoader { 28 | @Override 29 | public ServerActionTask getTaskFromCurrentRow(ResultSet resultSet, Map loadedTasks) throws SQLException { 30 | return new ServerActionTask( 31 | resultSet.getLong(1), 32 | resultSet.getLong(2), 33 | ServerActionTaskType.valueOf(resultSet.getString(4)), 34 | resultSet.getString(5), 35 | true); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandCreate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandCreate extends SubCommand { 27 | 28 | public SubCommandCreate(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "create", 32 | "create", 33 | "Create a new ServerSign", 34 | "create", "cr", "new" 35 | ); 36 | } 37 | 38 | @Override 39 | public void execute(boolean verbose) { 40 | applyMeta(SVSMetaKey.CREATE, new SVSMetaValue(1)); 41 | if (verbose) msg(Message.RIGHT_CLICK_CREATE); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/PlayerUniqueIdMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import org.bukkit.configuration.MemorySection; 21 | 22 | import java.util.UUID; 23 | 24 | public class PlayerUniqueIdMapper implements IPersistenceMapper { 25 | private MemorySection memorySection; 26 | 27 | @Override 28 | public void setMemorySection(MemorySection memorySection) { 29 | this.memorySection = memorySection; 30 | } 31 | 32 | @Override 33 | public UUID getValue(String path) { 34 | String string = memorySection.getString(path); 35 | try { 36 | return UUID.fromString(string); 37 | } catch (IllegalArgumentException ex) { 38 | return null; 39 | } 40 | } 41 | 42 | @Override 43 | public void setValue(String path, UUID value) { 44 | memorySection.set(path, value.toString()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PermissionGrantPlayerTaskLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | import de.czymm.serversigns.taskmanager.datastorage.ISQLiteTaskLoader; 22 | 23 | import java.sql.ResultSet; 24 | import java.sql.SQLException; 25 | import java.util.Map; 26 | import java.util.UUID; 27 | 28 | public class PermissionGrantPlayerTaskLoader implements ISQLiteTaskLoader { 29 | @Override 30 | public PermissionGrantPlayerTask getTaskFromCurrentRow(ResultSet resultSet, Map loadedTasks) throws SQLException { 31 | return new PermissionGrantPlayerTask( 32 | resultSet.getLong(1), 33 | resultSet.getLong(2), 34 | resultSet.getString(5), 35 | UUID.fromString(resultSet.getString(6)), 36 | true); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/CancelEnumMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import de.czymm.serversigns.signs.CancelMode; 21 | import org.bukkit.configuration.MemorySection; 22 | 23 | public class CancelEnumMapper implements IPersistenceMapper { 24 | private MemorySection memorySection; 25 | 26 | @Override 27 | public void setMemorySection(MemorySection memorySection) { 28 | this.memorySection = memorySection; 29 | } 30 | 31 | @Override 32 | public CancelMode getValue(String path) { 33 | try { 34 | return Enum.valueOf(CancelMode.class, memorySection.getString(path)); 35 | } catch (IllegalArgumentException | NullPointerException ex) { 36 | return null; 37 | } 38 | } 39 | 40 | @Override 41 | public void setValue(String path, CancelMode value) { 42 | memorySection.set(path, value.toString()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PlayerActionTaskLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | import de.czymm.serversigns.taskmanager.datastorage.ISQLiteTaskLoader; 22 | 23 | import java.sql.ResultSet; 24 | import java.sql.SQLException; 25 | import java.util.Map; 26 | import java.util.UUID; 27 | 28 | public class PlayerActionTaskLoader implements ISQLiteTaskLoader { 29 | @Override 30 | public PlayerActionTask getTaskFromCurrentRow(ResultSet resultSet, Map loadedTasks) throws SQLException { 31 | return new PlayerActionTask( 32 | resultSet.getLong(1), 33 | resultSet.getLong(2), 34 | PlayerActionTaskType.valueOf(resultSet.getString(4)), 35 | resultSet.getString(5), 36 | UUID.fromString(resultSet.getString(6)), 37 | true); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/hooks/EssentialsHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.hooks; 19 | 20 | import com.earth2me.essentials.Essentials; 21 | import com.earth2me.essentials.User; 22 | import de.czymm.serversigns.ServerSignsPlugin; 23 | import org.bukkit.Bukkit; 24 | import org.bukkit.entity.Player; 25 | 26 | public class EssentialsHook { 27 | 28 | protected ServerSignsPlugin pl; 29 | 30 | private Essentials essentials; 31 | 32 | public EssentialsHook(ServerSignsPlugin plugin) throws Exception { 33 | pl = plugin; 34 | essentials = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials"); 35 | if (essentials == null || !essentials.isEnabled()) throw new Exception(); 36 | } 37 | 38 | public String getNickname(Player player) { 39 | User user = essentials.getUser(player); 40 | if (user != null) { 41 | return user.getNickname(); 42 | } 43 | 44 | return player.getDisplayName(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/HasPermOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import org.bukkit.entity.Player; 23 | 24 | public class HasPermOperator extends ConditionalOperator { 25 | 26 | public HasPermOperator() { 27 | super("hasPerm", true); 28 | } 29 | 30 | @Override 31 | public ParameterValidityResponse checkParameterValidity(String params) { 32 | return new ParameterValidityResponse(true); // Anything can be a permission node 33 | } 34 | 35 | @Override 36 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 37 | if (params == null) { 38 | return false; 39 | } 40 | if (executor == null) { 41 | return true; // Console 42 | } 43 | 44 | return executor.hasPermission(params); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/hooks/HookWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.hooks; 19 | 20 | public class HookWrapper { 21 | 22 | private E hook; 23 | private boolean hooked = false; 24 | 25 | private Class clazz; 26 | private Class[] paramClasses; 27 | private Object[] paramObjects; 28 | 29 | public HookWrapper(Class instantiationClass, Class[] parameterClasses, Object[] parameterObjects) { 30 | this.clazz = instantiationClass; 31 | this.paramClasses = parameterClasses; 32 | this.paramObjects = parameterObjects; 33 | } 34 | 35 | public void instantiateHook() throws Exception { 36 | hook = clazz.getConstructor(paramClasses).newInstance(paramObjects); 37 | hooked = true; 38 | } 39 | 40 | public boolean isHooked() { 41 | return hooked; 42 | } 43 | 44 | public void setHooked(boolean val) { 45 | hooked = val; 46 | } 47 | 48 | public E getHook() { 49 | return hook; 50 | } 51 | } -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandRemove.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandRemove extends SubCommand { 27 | protected String usage; 28 | 29 | public SubCommandRemove(ServerSignsPlugin plugin) { 30 | super( 31 | plugin, 32 | "remove", 33 | "remove [line number]", 34 | "Remove a ServerSign, or just a specific command", 35 | "remove", "rem", "del", "delete" 36 | ); 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | applyMeta(SVSMetaKey.REMOVE, new SVSMetaValue(argInt(0, -1))); 42 | if (verbose) msg(Message.RIGHT_CLICK_REMOVE_COMMAND); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandResetCooldown.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandResetCooldown extends SubCommand { 27 | public SubCommandResetCooldown(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "reset_cooldown", 31 | "resetcd", 32 | "Reset the cooldown data for a ServerSign", 33 | "cdr", "cooldownreset", "cdreset", "resetcooldown", "rcd", "resetcd" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | applyMeta(SVSMetaKey.COOLDOWN_RESET, new SVSMetaValue(true)); 40 | if (verbose) msg(Message.RIGHT_CLICK_RESET_COOLDOWN); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/LoopIsOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import de.czymm.serversigns.utils.NumberUtils; 23 | import org.bukkit.entity.Player; 24 | 25 | public class LoopIsOperator extends ConditionalOperator { 26 | 27 | public LoopIsOperator() { 28 | super("loopIs", true); 29 | } 30 | 31 | @Override 32 | public ParameterValidityResponse checkParameterValidity(String params) { 33 | return new ParameterValidityResponse(NumberUtils.isInt(params), "Parameter must be a single integer"); 34 | } 35 | 36 | @Override 37 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 38 | if (params == null) { 39 | return false; 40 | } 41 | 42 | int loop = NumberUtils.parseInt(params); 43 | return executingSign.getCurrentLoop() == loop; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/PlayerActionTaskTypeEnumMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import de.czymm.serversigns.taskmanager.tasks.PlayerActionTaskType; 21 | import org.bukkit.configuration.MemorySection; 22 | 23 | public class PlayerActionTaskTypeEnumMapper implements IPersistenceMapper { 24 | private MemorySection memorySection; 25 | 26 | @Override 27 | public void setMemorySection(MemorySection memorySection) { 28 | this.memorySection = memorySection; 29 | } 30 | 31 | @Override 32 | public PlayerActionTaskType getValue(String path) { 33 | try { 34 | return Enum.valueOf(PlayerActionTaskType.class, memorySection.getString(path)); 35 | } catch (IllegalArgumentException | NullPointerException ex) { 36 | return null; 37 | } 38 | } 39 | 40 | @Override 41 | public void setValue(String path, PlayerActionTaskType value) { 42 | memorySection.set(path, value.toString()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/ServerActionTaskTypeEnumMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import de.czymm.serversigns.taskmanager.tasks.ServerActionTaskType; 21 | import org.bukkit.configuration.MemorySection; 22 | 23 | public class ServerActionTaskTypeEnumMapper implements IPersistenceMapper { 24 | private MemorySection memorySection; 25 | 26 | @Override 27 | public void setMemorySection(MemorySection memorySection) { 28 | this.memorySection = memorySection; 29 | } 30 | 31 | @Override 32 | public ServerActionTaskType getValue(String path) { 33 | try { 34 | return Enum.valueOf(ServerActionTaskType.class, memorySection.getString(path)); 35 | } catch (IllegalArgumentException | NullPointerException ex) { 36 | return null; 37 | } 38 | } 39 | 40 | @Override 41 | public void setValue(String path, ServerActionTaskType value) { 42 | memorySection.set(path, value.toString()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/UsesTallyIsOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import de.czymm.serversigns.utils.NumberUtils; 23 | import org.bukkit.entity.Player; 24 | 25 | public class UsesTallyIsOperator extends ConditionalOperator { 26 | 27 | public UsesTallyIsOperator() { 28 | super("usesTallyIs", true); 29 | } 30 | 31 | @Override 32 | public ParameterValidityResponse checkParameterValidity(String params) { 33 | return new ParameterValidityResponse(NumberUtils.isInt(params), "Parameter must be a single integer"); 34 | } 35 | 36 | @Override 37 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 38 | if (params == null) { 39 | return false; 40 | } 41 | 42 | int tally = NumberUtils.parseInt(params); 43 | return executingSign.getUseTally() == tally; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandReloadSigns.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.translations.Message; 23 | 24 | public class SubCommandReloadSigns extends SubCommand { 25 | public SubCommandReloadSigns(ServerSignsPlugin plugin) { 26 | super( 27 | plugin, 28 | "reload_signs", 29 | "reloadSigns", 30 | "Reload all ServerSigns from disk", 31 | "reloadsigns", "reloadsign", "reloads", "rls", "rlsigns" 32 | ); 33 | } 34 | 35 | @Override 36 | public void execute(boolean verbose) { 37 | if (verbose) { 38 | if (plugin.serverSignsManager.populateSignsMap(plugin.serverSignsManager.prepareServerSignsSet())) { 39 | msg(Message.RELOAD_SUCCESS); 40 | } else { 41 | msg(Message.RELOAD_SIGNS_FAIL); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/QueueConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.concurrent.BlockingQueue; 23 | 24 | public class QueueConsumer implements Runnable { 25 | private final BlockingQueue queue; 26 | private final ITaskExecutor taskExecutor; 27 | private volatile boolean running = true; 28 | 29 | public QueueConsumer(BlockingQueue queue, ITaskExecutor taskExecutor) { 30 | this.queue = queue; 31 | this.taskExecutor = taskExecutor; 32 | } 33 | 34 | public void stop() { 35 | running = false; 36 | } 37 | 38 | @Override 39 | public void run() { 40 | while (running) { 41 | try { 42 | List tasksToRun = new ArrayList<>(); 43 | tasksToRun.add(queue.take()); 44 | queue.drainTo(tasksToRun); 45 | taskExecutor.runTasks(tasksToRun); 46 | } catch (InterruptedException ignored) { 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandAdd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | 24 | public class SubCommandAdd extends SubCommand { 25 | 26 | public SubCommandAdd(ServerSignsPlugin plugin) { 27 | super( 28 | plugin, 29 | "add", 30 | "add [type] [params] ", 31 | "Bind a command to a new or existing ServerSign", 32 | "add", "a" 33 | ); 34 | } 35 | 36 | @Override 37 | public void execute(boolean verbose) { 38 | if (!argSet(0)) { 39 | if (verbose) sendUsage(); 40 | return; 41 | } 42 | 43 | String command = loopArgs(0); 44 | if (!CommandUtils.isCommandSafe(command, plugin, sender)) { 45 | return; 46 | } 47 | 48 | CommandUtils.applyServerSignCommandMeta(command, plugin, sender, verbose, SVSMetaKey.ADD); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandVoid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaManager; 23 | 24 | import java.util.UUID; 25 | 26 | public class SubCommandVoid extends SubCommand { 27 | public SubCommandVoid(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "void", 31 | "void", 32 | "Invalidates any pending actions you may have", 33 | "void" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | UUID id = player == null ? SVSMetaManager.CONSOLE_UUID : player.getUniqueId(); 40 | if (SVSMetaManager.hasMeta(id)) { 41 | SVSMetaManager.removeMeta(id); 42 | SVSMetaManager.removeSpecialMeta(id); // Just remove special meta if it exists here, don't check/error 43 | msg("Success!"); 44 | } else { 45 | sendUsage(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/TaskDeleter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | 22 | import java.sql.Connection; 23 | import java.sql.PreparedStatement; 24 | import java.sql.SQLException; 25 | import java.util.List; 26 | 27 | public class TaskDeleter implements ISQLiteTaskDeleter { 28 | private static final String SQL_DELETE_TASK = "DELETE FROM Task WHERE TaskId IS ?"; 29 | private PreparedStatement statement; 30 | 31 | @Override 32 | public void deleteTask(Connection connection, TaskManagerTask task, List closeChain) throws SQLException { 33 | if (statement == null) { 34 | statement = connection.prepareStatement(SQL_DELETE_TASK); 35 | closeChain.add(this); 36 | } 37 | 38 | statement.setLong(1, task.getTaskID()); 39 | statement.execute(); 40 | } 41 | 42 | @Override 43 | public void close() throws SQLException { 44 | try { 45 | statement.close(); 46 | } finally { 47 | statement = null; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandSilent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandSilent extends SubCommand { 27 | 28 | public SubCommandSilent(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "silent", 32 | "silent {true | false}", 33 | "Set whether a ServerSign should display internal messages to the user", 34 | "silent", "sil", "quiet", "mute" 35 | ); 36 | } 37 | 38 | @Override 39 | public void execute(boolean verbose) { 40 | if (!argSet(0)) { 41 | if (verbose) sendUsage(); 42 | return; 43 | } 44 | 45 | applyMeta(SVSMetaKey.SILENT, new SVSMetaValue(!argBool(0))); // Invert their input as we want to know whether it's verbose or not 46 | if (verbose) msg(Message.RIGHT_CLICK_APPLY); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/utils/formatter/MessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package de.czymm.serversigns.utils.formatter; 18 | 19 | import de.czymm.serversigns.hooks.HookManager; 20 | import org.bukkit.ChatColor; 21 | import org.bukkit.command.CommandSender; 22 | 23 | public abstract class MessageFormatter { 24 | 25 | public static String toColor(final String message) { 26 | return ChatColor.translateAlternateColorCodes('&', message); 27 | } 28 | 29 | /** 30 | * Format a message to send to a player 31 | * 32 | * @param player Player to use for format 33 | * @param message Message to format 34 | * @return Formatted message 35 | */ 36 | public abstract String format(CommandSender player, String message); 37 | 38 | /** 39 | * Get the formatter to use to format messages 40 | * 41 | * @param hookManager HookManager used to verify placeholder is loaded 42 | * @return MessageFormatter 43 | */ 44 | public static MessageFormatter getFormatter(final HookManager hookManager) { 45 | if (hookManager.placeholderAPI.isHooked()) 46 | return new PlaceholderMessageFormatter(); 47 | return new BasicMessageFormatter(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandXP.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandXP extends SubCommand { 27 | public SubCommandXP(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "xp", 31 | "xp ", 32 | "Set an experience levels cost on an existing ServerSign", 33 | "xp", "xpprice", "exp" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | if (!argSet(0)) { 40 | if (verbose) sendUsage(); 41 | return; 42 | } 43 | 44 | int levels = argInt(0, -1); 45 | if (levels < 0) { 46 | if (verbose) msg(Message.XP_COST_INVALID); 47 | return; 48 | } 49 | 50 | applyMeta(SVSMetaKey.XP, new SVSMetaValue(levels)); 51 | if (verbose) msg(Message.XP_COST_BIND); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandSetPrice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandSetPrice extends SubCommand { 27 | public SubCommandSetPrice(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "set_price", 31 | "setprice ", 32 | "Add a monetary cost to an existing ServerSign", 33 | "spr", "setprice", "priceset", "price" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | if (!argSet(0)) { 40 | if (verbose) sendUsage(); 41 | return; 42 | } 43 | 44 | if (argDouble(0, -1.0) < 0) { 45 | if (verbose) sendUsage(); 46 | return; 47 | } 48 | 49 | applyMeta(SVSMetaKey.PRICE, new SVSMetaValue(argDouble(0))); 50 | if (verbose) msg(Message.RIGHT_CLICK_SET_PRICE); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/StringLongHashMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import org.bukkit.configuration.MemorySection; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map.Entry; 24 | 25 | public class StringLongHashMapper implements IPersistenceMapper> { 26 | private MemorySection memorySection; 27 | 28 | @Override 29 | public void setMemorySection(MemorySection memorySection) { 30 | this.memorySection = memorySection; 31 | } 32 | 33 | @Override 34 | public HashMap getValue(String path) { 35 | HashMap map = new HashMap<>(); 36 | if (memorySection.getConfigurationSection(path) == null) return map; 37 | for (String key : memorySection.getConfigurationSection(path).getKeys(false)) { 38 | map.put(key, memorySection.getLong(path + "." + key)); 39 | } 40 | 41 | return map; 42 | } 43 | 44 | @Override 45 | public void setValue(String path, HashMap val) { 46 | for (Entry entry : val.entrySet()) { 47 | memorySection.set(path + "." + entry.getKey().toString(), entry.getValue()); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaManager; 24 | import de.czymm.serversigns.meta.SVSMetaValue; 25 | import de.czymm.serversigns.translations.Message; 26 | 27 | public class SubCommandSelect extends SubCommand { 28 | 29 | public SubCommandSelect(ServerSignsPlugin plugin) { 30 | super( 31 | plugin, 32 | "select", 33 | "select", 34 | "Select a ServerSign for future commands to be automatically applied to", 35 | "select", "sel" 36 | ); 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | if (SVSMetaManager.hasSpecialMeta(player.getUniqueId(), SVSMetaKey.SELECT)) { 42 | SVSMetaManager.removeSpecialMeta(player.getUniqueId()); 43 | if (verbose) msg(Message.SIGN_DESELECTED); 44 | return; 45 | } 46 | 47 | applyMeta(SVSMetaKey.SELECT, new SVSMetaValue(1)); 48 | if (verbose) msg(Message.RIGHT_CLICK_SELECT); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/ServerActionTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 22 | import org.bukkit.Bukkit; 23 | 24 | public class ServerActionTask extends TaskManagerTask { 25 | 26 | public ServerActionTask(long runAt, ServerActionTaskType actionType, String action, boolean alwaysPersisted) { 27 | super(runAt, actionType, action, alwaysPersisted); 28 | } 29 | 30 | protected ServerActionTask(long taskID, long runAt, ServerActionTaskType actionType, String action, boolean alwaysPersisted) { 31 | super(taskID, runAt, actionType, action, alwaysPersisted); 32 | } 33 | 34 | @Override 35 | public TaskStatus runTask(ServerSignsPlugin plugin) { 36 | switch (getSubType()) { 37 | case COMMAND: 38 | plugin.serverCommand(getData()); 39 | break; 40 | case BROADCAST: 41 | Bukkit.broadcastMessage(getData()); 42 | break; 43 | } 44 | 45 | return TaskStatus.SUCCESS; 46 | } 47 | 48 | @Override 49 | public TaskType getTaskType() { 50 | return TaskType.SERVER; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandReloadConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.config.ConfigLoadingException; 23 | import de.czymm.serversigns.translations.Message; 24 | import de.czymm.serversigns.translations.NoDefaultException; 25 | import org.bukkit.Bukkit; 26 | 27 | public class SubCommandReloadConfig extends SubCommand { 28 | public SubCommandReloadConfig(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "reload_config", 32 | "reloadConfig", 33 | "Reload the config.yml & translations files from disk", 34 | "reloadconfig", "reloadconf", "reloadc", "rlc", "rlconf" 35 | ); 36 | } 37 | 38 | @Override 39 | public void execute(boolean verbose) { 40 | try { 41 | plugin.loadConfig(plugin.getDataFolder().toPath()); 42 | if (verbose) msg(Message.RELOAD_CONFIG_SUCCESS); 43 | } catch (NoDefaultException | ConfigLoadingException ex) { 44 | if (verbose) msg(Message.RELOAD_CONFIG_FAIL); 45 | Bukkit.getPluginManager().disablePlugin(plugin); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandEdit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | 25 | public class SubCommandEdit extends SubCommand { 26 | public SubCommandEdit(ServerSignsPlugin plugin) { 27 | super( 28 | plugin, 29 | "edit", 30 | "edit ", 31 | "Edit a command on an existing ServerSign", 32 | "edit", "ed" 33 | ); 34 | } 35 | 36 | @Override 37 | public void execute(boolean verbose) { 38 | if (!argSet(1)) { 39 | if (verbose) sendUsage(); 40 | return; 41 | } 42 | 43 | int line = argInt(0, -1); 44 | if (line < 1) { 45 | sendUsage(); 46 | return; 47 | } 48 | 49 | String command = loopArgs(1); 50 | if (!CommandUtils.isCommandSafe(command, plugin, sender)) { 51 | return; 52 | } 53 | 54 | CommandUtils.applyServerSignCommandMeta(command, plugin, sender, verbose, SVSMetaKey.EDIT, new SVSMetaValue(line)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.ChatColor; 21 | import org.bukkit.inventory.ItemStack; 22 | import org.bukkit.inventory.meta.ItemMeta; 23 | 24 | public class ItemName extends ItemData implements IItemData { 25 | private static ItemName i = new ItemName(); 26 | 27 | public static ItemName get() { 28 | return i; 29 | } 30 | 31 | public ItemName() { 32 | super(ItemPart.NAME, new String[]{"na.", "name.", "displayname.", "display_name."}); 33 | setApplyToMeta(true); 34 | } 35 | 36 | @Override 37 | public ItemStack applyValue(ItemStack item, String value) throws DataException { 38 | if (item == null) return null; 39 | 40 | ItemMeta meta = applyMetaValue(item.getItemMeta(), value); 41 | item.setItemMeta(meta); 42 | 43 | return item; 44 | } 45 | 46 | @Override 47 | public ItemMeta applyMetaValue(ItemMeta meta, String value) throws DataException { 48 | if (!value.isEmpty()) { 49 | meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', value).replaceAll("_", " ")); 50 | return meta; 51 | } 52 | 53 | throw new DataException("Empty strings cannot be used for ItemStack names!"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemLore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.ChatColor; 21 | import org.bukkit.inventory.ItemStack; 22 | import org.bukkit.inventory.meta.ItemMeta; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | public class ItemLore extends ItemData implements IItemData { 28 | private static ItemLore i = new ItemLore(); 29 | 30 | public static ItemLore get() { 31 | return i; 32 | } 33 | 34 | public ItemLore() { 35 | super(ItemPart.LORES, new String[]{"lo.", "lores.", "lore."}); 36 | setApplyToMeta(true); 37 | } 38 | 39 | @Override 40 | public ItemStack applyValue(ItemStack item, String value) throws DataException { 41 | if (item == null) return null; 42 | 43 | ItemMeta meta = applyMetaValue(item.getItemMeta(), value); 44 | item.setItemMeta(meta); 45 | 46 | return item; 47 | } 48 | 49 | @Override 50 | public ItemMeta applyMetaValue(ItemMeta meta, String value) throws DataException { 51 | List lores = meta.hasLore() ? meta.getLore() : new ArrayList(); 52 | lores.add(ChatColor.translateAlternateColorCodes('&', value.replaceAll("_", " "))); 53 | meta.setLore(lores); 54 | 55 | return meta; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandResetAllCooldowns.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.signs.ServerSign; 23 | import de.czymm.serversigns.translations.Message; 24 | 25 | import java.util.Iterator; 26 | 27 | public class SubCommandResetAllCooldowns extends SubCommand { 28 | public SubCommandResetAllCooldowns(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "reset_all_cooldowns", 32 | "resetallcd", 33 | "Reset all ServerSigns cooldowns across all signs", 34 | "resetallcd", "cdra", "cooldownresetall", "cdresetall", "rcda", "resetcdall", "resetallcooldown" 35 | ); 36 | 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | Iterator iterator = plugin.serverSignsManager.getSigns().iterator(); 42 | while (iterator.hasNext()) { 43 | ServerSign sign = iterator.next(); 44 | sign.setLastGlobalUse(0); 45 | sign.getLastUse().clear(); 46 | plugin.serverSignsManager.save(sign); 47 | } 48 | 49 | if (verbose) msg(Message.ALL_COOLDOWNS_RESET); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemAmount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.inventory.ItemStack; 21 | import org.bukkit.inventory.meta.ItemMeta; 22 | 23 | public class ItemAmount extends ItemData implements IItemData { 24 | private static ItemAmount i = new ItemAmount(); 25 | 26 | public static ItemAmount get() { 27 | return i; 28 | } 29 | 30 | public ItemAmount() { 31 | super(ItemPart.AMOUNT, new String[]{"am.", "amount.", "count."}); 32 | } 33 | 34 | @Override 35 | public ItemStack applyValue(ItemStack item, String value) throws DataException { 36 | if (item == null) return null; 37 | 38 | int amount = 0; 39 | try { 40 | amount = Integer.parseInt(value); 41 | } catch (NumberFormatException ex) { 42 | throw new DataException(amount + " is not a valid ItemStack amount (integer)!"); 43 | } 44 | 45 | if (amount < 1) 46 | throw new DataException(amount + " is not a valid ItemStack amount (must be >= 1)"); 47 | 48 | item.setAmount(amount); 49 | return item; 50 | } 51 | 52 | @Override 53 | public ItemMeta applyMetaValue(ItemMeta item, String value) throws DataException { 54 | throw new UnsupportedOperationException(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandInsert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | 25 | public class SubCommandInsert extends SubCommand { 26 | public SubCommandInsert(ServerSignsPlugin plugin) { 27 | super( 28 | plugin, 29 | "insert", 30 | "insert ", 31 | "Insert a new command at the given index on an existing ServerSign", 32 | "insert", "ins" 33 | ); 34 | } 35 | 36 | @Override 37 | public void execute(boolean verbose) { 38 | if (!argSet(1)) { 39 | if (verbose) sendUsage(); 40 | return; 41 | } 42 | 43 | int line = argInt(0, -1); 44 | if (line < 1) { 45 | if (verbose) sendUsage(); 46 | return; 47 | } 48 | 49 | String command = loopArgs(1); 50 | if (!CommandUtils.isCommandSafe(command, plugin, sender)) { 51 | return; 52 | } 53 | 54 | CommandUtils.applyServerSignCommandMeta(command, plugin, sender, verbose, SVSMetaKey.INSERT, new SVSMetaValue(line)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandSetLoops.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandSetLoops extends SubCommand { 27 | public SubCommandSetLoops(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "set_loops", 31 | "setloops [loop delay (secs)]", 32 | "Convert an existing ServerSign to a looped ServerSign (60s by default)", 33 | "setloops", "setl", "setloop" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | if (!argSet(0)) { 40 | if (verbose) sendUsage(); 41 | return; 42 | } 43 | 44 | if (argInt(1, 60) < 1) { 45 | if (verbose) msg(Message.DELAY_GREATER_THAN_ZERO); 46 | if (verbose) sendUsage(); 47 | return; 48 | } 49 | 50 | applyMeta(SVSMetaKey.LOOP, new SVSMetaValue(argInt(0)), new SVSMetaValue(argInt(1, 60))); 51 | if (verbose) msg(Message.RIGHT_CLICK_BIND_LOOPS); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandSetUses.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandSetUses extends SubCommand { 27 | public SubCommandSetUses(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "set_uses", 31 | "setuses {0|}", 32 | "Limit this ServerSign to X number of uses", 33 | "setuses", "setuse", "uses" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | if (!argSet(0)) { 40 | if (verbose) sendUsage(); 41 | return; 42 | } 43 | 44 | int uses = argInt(0, -1); 45 | if (uses < 0) { 46 | if (verbose) msg(Message.USES_GREATER_ZERO); 47 | return; 48 | } 49 | 50 | applyMeta(SVSMetaKey.USES, new SVSMetaValue(uses)); 51 | 52 | if (verbose) { 53 | if (uses == 0) msg(Message.RIGHT_CLICK_REMOVE_USES); 54 | else msg(Message.RIGHT_CLICK_SET_USES); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemDamage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.inventory.ItemStack; 21 | import org.bukkit.inventory.meta.ItemMeta; 22 | 23 | public class ItemDamage extends ItemData implements IItemData { 24 | private static ItemDamage i = new ItemDamage(); 25 | 26 | public static ItemDamage get() { 27 | return i; 28 | } 29 | 30 | public ItemDamage() { 31 | super(ItemPart.DAMAGE, new String[]{"du.", "durability.", "damage.", "dura."}); 32 | } 33 | 34 | @Override 35 | public ItemStack applyValue(ItemStack item, String value) throws DataException { 36 | if (item == null) return null; 37 | 38 | short damage = 0; 39 | try { 40 | damage = (short) Integer.parseInt(value); 41 | } catch (NumberFormatException ex) { 42 | throw new DataException(damage + " is not a valid ItemStack durability (integer)!"); 43 | } 44 | 45 | if (damage < 0) 46 | throw new DataException(damage + " is not a valid ItemStack durability (must be >= 0)"); 47 | 48 | item.setDurability(damage); 49 | return item; 50 | } 51 | 52 | @Override 53 | public ItemMeta applyMetaValue(ItemMeta item, String value) throws DataException { 54 | throw new UnsupportedOperationException(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/IsAfterOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import de.czymm.serversigns.utils.NumberUtils; 23 | import de.czymm.serversigns.utils.TimeUtils; 24 | import org.bukkit.entity.Player; 25 | 26 | public class IsAfterOperator extends ConditionalOperator { 27 | 28 | public IsAfterOperator() { 29 | super("isAfter", true); 30 | } 31 | 32 | @Override 33 | public ParameterValidityResponse checkParameterValidity(String params) { 34 | boolean isValid = true; 35 | if (params.length() != 13 || !NumberUtils.isInt(params.substring(0, 6)) || !NumberUtils.isInt(params.substring(7))) { 36 | isValid = false; 37 | } 38 | return new ParameterValidityResponse(isValid, "Parameter must be a date & time string in the format DDMMYY,HHMMSS - note the comma separator"); 39 | } 40 | 41 | @Override 42 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 43 | if (params == null) { 44 | return false; 45 | } 46 | 47 | long timestamp = TimeUtils.convertDSDDFToEpochMillis(params, plugin.config.getTimeZone()); 48 | return System.currentTimeMillis() >= timestamp; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/IsBeforeOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import de.czymm.serversigns.utils.NumberUtils; 23 | import de.czymm.serversigns.utils.TimeUtils; 24 | import org.bukkit.entity.Player; 25 | 26 | public class IsBeforeOperator extends ConditionalOperator { 27 | 28 | public IsBeforeOperator() { 29 | super("isBefore", true); 30 | } 31 | 32 | @Override 33 | public ParameterValidityResponse checkParameterValidity(String params) { 34 | boolean isValid = true; 35 | if (params.length() != 13 || !NumberUtils.isInt(params.substring(0, 6)) || !NumberUtils.isInt(params.substring(7))) { 36 | isValid = false; 37 | } 38 | return new ParameterValidityResponse(isValid, "Parameter must be a date & time string in the format DDMMYY,HHMMSS - note the comma separator"); 39 | } 40 | 41 | @Override 42 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 43 | if (params == null) { 44 | return false; 45 | } 46 | 47 | long timestamp = TimeUtils.convertDSDDFToEpochMillis(params, plugin.config.getTimeZone()); 48 | return System.currentTimeMillis() < timestamp; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemPart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | public enum ItemPart { 21 | TYPE(ItemType.get()), 22 | AMOUNT(ItemAmount.get()), 23 | DAMAGE(ItemDamage.get()), 24 | ENCHANTS(ItemEnchants.get()), 25 | NAME(ItemName.get()), 26 | LORES(ItemLore.get()), 27 | COLOURS(ItemColour.get()) 28 | 29 | // End 30 | ; 31 | 32 | private ItemData attached; 33 | private String[] prefixes; 34 | 35 | ItemPart(ItemData attached) { 36 | this.attached = attached; 37 | this.prefixes = attached.getMatcherPrefix(); 38 | } 39 | 40 | public ItemData getAttachedData() { 41 | return this.attached; 42 | } 43 | 44 | public String[] getPrefixes() { 45 | return this.prefixes; 46 | } 47 | 48 | public static ItemPart getPartFromPrefix(String input) { 49 | if (input.length() < 2) return null; 50 | 51 | for (ItemPart part : ItemPart.values()) { 52 | for (String prefix : part.getPrefixes()) { 53 | if (prefix.endsWith(".")) { 54 | if (input.equalsIgnoreCase(prefix.substring(0, prefix.length() - 1))) 55 | return part; 56 | } else if (input.equalsIgnoreCase(prefix)) 57 | return part; 58 | } 59 | } 60 | 61 | return null; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/ItemSearchCriteriaMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import de.czymm.serversigns.itemdata.ItemSearchCriteria; 21 | import org.bukkit.configuration.MemorySection; 22 | 23 | public class ItemSearchCriteriaMapper implements IPersistenceMapper { 24 | private MemorySection memorySection; 25 | 26 | @Override 27 | public void setMemorySection(MemorySection memorySection) { 28 | this.memorySection = memorySection; 29 | } 30 | 31 | @Override 32 | public ItemSearchCriteria getValue(String path) { 33 | if (memorySection.getConfigurationSection(path) == null) 34 | return new ItemSearchCriteria(false, false, false, false); 35 | return new ItemSearchCriteria(memorySection.getBoolean(path + ".enchants"), memorySection.getBoolean(path + ".name"), 36 | memorySection.getBoolean(path + ".lores"), memorySection.getBoolean(path + ".durability")); 37 | } 38 | 39 | @Override 40 | public void setValue(String path, ItemSearchCriteria val) { 41 | memorySection.set(path + ".enchants", val.getEnchantsCriteria()); 42 | memorySection.set(path + ".name", val.getIgnoreName()); 43 | memorySection.set(path + ".lores", val.getIgnoreLore()); 44 | memorySection.set(path + ".durability", val.getIgnoreDurability()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/PlayerTaskDeleter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | 22 | import java.sql.Connection; 23 | import java.sql.PreparedStatement; 24 | import java.sql.SQLException; 25 | import java.util.List; 26 | 27 | public class PlayerTaskDeleter implements ISQLiteTaskDeleter { 28 | private static final String SQL_DELETE_PLAYER_TASK = "DELETE FROM PlayerTask WHERE TaskId IS ?"; 29 | private final TaskDeleter taskDeleter; 30 | private PreparedStatement statement; 31 | 32 | public PlayerTaskDeleter(TaskDeleter taskDeleter) { 33 | this.taskDeleter = taskDeleter; 34 | } 35 | 36 | @Override 37 | public void deleteTask(Connection connection, TaskManagerTask task, List closeChain) throws SQLException { 38 | taskDeleter.deleteTask(connection, task, closeChain); 39 | 40 | if (statement == null) { 41 | statement = connection.prepareStatement(SQL_DELETE_PLAYER_TASK); 42 | closeChain.add(this); 43 | } 44 | 45 | statement.setLong(1, task.getTaskID()); 46 | statement.execute(); 47 | } 48 | 49 | @Override 50 | public void close() throws SQLException { 51 | try { 52 | statement.close(); 53 | } finally { 54 | statement = null; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/CommandType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing; 19 | 20 | import de.czymm.serversigns.taskmanager.tasks.PermissionGrantPlayerTaskType; 21 | import de.czymm.serversigns.taskmanager.tasks.PermissionRemovePlayerTaskType; 22 | import de.czymm.serversigns.taskmanager.tasks.PlayerActionTaskType; 23 | import de.czymm.serversigns.taskmanager.tasks.ServerActionTaskType; 24 | 25 | public enum CommandType { 26 | SERVER_COMMAND(ServerActionTaskType.COMMAND), 27 | BROADCAST(ServerActionTaskType.BROADCAST), 28 | CHAT(PlayerActionTaskType.CHAT), 29 | MESSAGE(PlayerActionTaskType.MESSAGE), 30 | BLANK_MESSAGE(PlayerActionTaskType.BLANK_MESSAGE), 31 | PLAYER_COMMAND(PlayerActionTaskType.COMMAND), 32 | OP_COMMAND(PlayerActionTaskType.OP_COMMAND), 33 | PERMISSION_GRANT(PermissionGrantPlayerTaskType.PERMISSION_GRANT), 34 | PERMISSION_REMOVE(PermissionRemovePlayerTaskType.PERMISSION_REMOVE), 35 | ADD_GROUP(PlayerActionTaskType.ADD_GROUP), 36 | DEL_GROUP(PlayerActionTaskType.DEL_GROUP), 37 | CONDITIONAL_IF(null), 38 | CONDITIONAL_ENDIF(null), 39 | RETURN(null), 40 | CANCEL_TASKS(PlayerActionTaskType.CANCEL_TASKS), 41 | DISPLAY_OPTIONS(null); 42 | 43 | private Object taskTypeObj; 44 | 45 | CommandType(Object taskObj) { 46 | this.taskTypeObj = taskObj; 47 | } 48 | 49 | public Object getTaskObject() { 50 | return taskTypeObj; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/TaskSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | 22 | import java.sql.Connection; 23 | import java.sql.PreparedStatement; 24 | import java.sql.SQLException; 25 | import java.util.List; 26 | 27 | public class TaskSaver implements ISQLiteTaskSaver { 28 | private static final String SQL_INSERT_TASK = "INSERT INTO Task (TaskId, RunAt, Type, SubType, Data)\n" + 29 | "VALUES (?, ?, ?, ?, ?)"; 30 | private PreparedStatement statement; 31 | 32 | @Override 33 | public void saveTask(Connection connection, TaskManagerTask task, List closeChain) throws SQLException { 34 | if (statement == null) { 35 | statement = connection.prepareStatement(SQL_INSERT_TASK); 36 | closeChain.add(this); 37 | } 38 | 39 | statement.setLong(1, task.getTaskID()); 40 | statement.setLong(2, task.getRunAt()); 41 | statement.setString(3, task.getTaskType().name()); 42 | statement.setString(4, task.getSubType().name()); 43 | statement.setString(5, task.getData()); 44 | statement.execute(); 45 | } 46 | 47 | @Override 48 | public void close() throws SQLException { 49 | try { 50 | statement.close(); 51 | } finally { 52 | statement = null; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandSetCooldown.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | import de.czymm.serversigns.utils.TimeUtils; 26 | 27 | public class SubCommandSetCooldown extends SubCommand { 28 | public SubCommandSetCooldown(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "set_cooldown", 32 | "setcooldown {s|m|h|d|w|mo}", 33 | "Set the per-player cooldown time for an existing ServerSign", 34 | "scd", "setcooldown" 35 | ); 36 | } 37 | 38 | @Override 39 | public void execute(boolean verbose) { 40 | if (!argSet(0)) { 41 | if (verbose) sendUsage(); 42 | return; 43 | } 44 | 45 | long cooldown = TimeUtils.getLengthFromString(arg(0)); 46 | if (cooldown == 0 && !arg(0).equals("0")) cooldown = -1; 47 | if (cooldown < 0) { 48 | if (verbose) msg(Message.NO_NUMBER); 49 | return; 50 | } 51 | 52 | applyMeta(SVSMetaKey.SET_COOLDOWN, new SVSMetaValue(cooldown / 1000)); 53 | if (verbose) msg(Message.RIGHT_CLICK_SET_COOLDOWN); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/legacy/LanguageYmlConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.legacy; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import org.bukkit.configuration.file.YamlConfiguration; 22 | 23 | import java.io.IOException; 24 | import java.nio.file.Files; 25 | import java.nio.file.Path; 26 | 27 | public class LanguageYmlConverter { 28 | 29 | public static void convertLanguagesFile(Path file, Path translationsDirectory) throws IOException { 30 | if (Files.exists(file)) { 31 | ServerSignsPlugin.log("Converting languages.yml to new translations system"); 32 | YamlConfiguration yaml = YamlConfiguration.loadConfiguration(file.toFile()); 33 | if (yaml.getConfigurationSection("") != null) { 34 | for (String language : yaml.getConfigurationSection("").getKeys(false)) { 35 | Path newFile = translationsDirectory.resolve(language + ".yml"); 36 | Files.createFile(newFile); 37 | 38 | YamlConfiguration newYaml = YamlConfiguration.loadConfiguration(newFile.toFile()); 39 | for (String key : yaml.getConfigurationSection(language).getKeys(false)) { 40 | newYaml.set(key, yaml.getString(language + "." + key)); 41 | } 42 | newYaml.save(newFile.toFile()); 43 | } 44 | } 45 | 46 | Files.delete(file); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandCancel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.signs.CancelMode; 25 | import de.czymm.serversigns.translations.Message; 26 | 27 | public class SubCommandCancel extends SubCommand { 28 | public SubCommandCancel(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "set_cancel", 32 | "cancel ", 33 | "Set if/when this sign should cancel the interact event. Available modes: always|never|success_only|fail_only", 34 | "cancel", "setcancel", "stopevent" 35 | ); 36 | } 37 | 38 | @Override 39 | public void execute(boolean verbose) { 40 | if (!argSet(0)) { 41 | if (verbose) sendUsage(); 42 | return; 43 | } 44 | 45 | String str = argStr(0); 46 | CancelMode mode; 47 | try { 48 | mode = CancelMode.valueOf(str.toUpperCase()); 49 | } catch (IllegalArgumentException ex) { 50 | if (verbose) sendUsage(); 51 | return; 52 | } 53 | 54 | applyMeta(SVSMetaKey.CANCEL, new SVSMetaValue(mode.name())); 55 | if (verbose) msg(Message.RIGHT_CLICK_APPLY); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandConfirmation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMeta; 23 | import de.czymm.serversigns.meta.SVSMetaKey; 24 | import de.czymm.serversigns.meta.SVSMetaManager; 25 | import de.czymm.serversigns.meta.SVSMetaValue; 26 | import de.czymm.serversigns.translations.Message; 27 | 28 | public class SubCommandConfirmation extends SubCommand { 29 | public SubCommandConfirmation(ServerSignsPlugin plugin) { 30 | super( 31 | plugin, 32 | "confirmation", 33 | "confirmation {true | false} [message]", 34 | "Set whether this sign should ask for confirmation before allowing use", 35 | "conf", "confirm", "confirmation", "cf" 36 | ); 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | if (!argSet(0)) { 42 | if (verbose) sendUsage(); 43 | return; 44 | } 45 | 46 | boolean value = argBool(0); 47 | SVSMeta meta = new SVSMeta(SVSMetaKey.CONFIRMATION, new SVSMetaValue(value)); 48 | if (value && argSet(1)) { 49 | meta.addValue(new SVSMetaValue(loopArgs(1))); 50 | } 51 | 52 | SVSMetaManager.setMeta(player, meta); 53 | if (verbose) msg(Message.RIGHT_CLICK_APPLY); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandReload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.config.ConfigLoadingException; 23 | import de.czymm.serversigns.translations.Message; 24 | import de.czymm.serversigns.translations.NoDefaultException; 25 | import org.bukkit.Bukkit; 26 | 27 | public class SubCommandReload extends SubCommand { 28 | public SubCommandReload(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "reload", 32 | "reload", 33 | "Reload config.yml, translation files, and all ServerSigns from disk", 34 | "reload", "rl" 35 | ); 36 | } 37 | 38 | @Override 39 | public void execute(boolean verbose) { 40 | try { 41 | plugin.loadConfig(plugin.getDataFolder().toPath()); 42 | } catch (NoDefaultException | ConfigLoadingException ex) { 43 | if (verbose) msg(Message.RELOAD_CONFIG_FAIL); 44 | Bukkit.getPluginManager().disablePlugin(plugin); 45 | return; 46 | } 47 | 48 | if (verbose) { 49 | if (!plugin.serverSignsManager.populateSignsMap(plugin.serverSignsManager.prepareServerSignsSet())) { 50 | msg(Message.RELOAD_SIGNS_FAIL); 51 | } 52 | msg(Message.RELOAD_SUCCESS); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandSetGlobalCooldown.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | import de.czymm.serversigns.utils.TimeUtils; 26 | 27 | public class SubCommandSetGlobalCooldown extends SubCommand { 28 | public SubCommandSetGlobalCooldown(ServerSignsPlugin plugin) { 29 | super( 30 | plugin, 31 | "set_global_cooldown", 32 | "setglobalcooldown {s|m|h|d|w|mo}", 33 | "Set the global cooldown time for an existing ServerSign", 34 | "sgcd", "setglobalcooldown" 35 | ); 36 | } 37 | 38 | @Override 39 | public void execute(boolean verbose) { 40 | if (!argSet(0)) { 41 | if (verbose) sendUsage(); 42 | return; 43 | } 44 | 45 | long cooldown = TimeUtils.getLengthFromString(arg(0)); 46 | if (cooldown == 0 && !arg(0).equals("0")) cooldown = -1; 47 | if (cooldown < 0) { 48 | if (verbose) msg(Message.NO_NUMBER); 49 | return; 50 | } 51 | 52 | applyMeta(SVSMetaKey.SET_GLOBAL_COOLDOWN, new SVSMetaValue(cooldown / 1000)); 53 | if (verbose) msg(Message.RIGHT_CLICK_SET_COOLDOWN); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/PersistTaskExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.ITaskExecutor; 21 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 22 | 23 | import java.util.List; 24 | 25 | public class PersistTaskExecutor implements ITaskExecutor { 26 | private final IDataStorageHandler dataStorageHandler; 27 | 28 | public PersistTaskExecutor(IDataStorageHandler dataStorageHandler) { 29 | this.dataStorageHandler = dataStorageHandler; 30 | } 31 | 32 | @Override 33 | public void runTasks(List tasks) { 34 | try (IDataStorageAccessor storage = dataStorageHandler.newDataStorageAccessor()) { 35 | for (PersistTask persistTask : tasks) { 36 | PersistAction persistAction = persistTask.getPersistAction(); 37 | TaskManagerTask taskManagerTask = persistTask.getTask(); 38 | 39 | if (persistAction == PersistAction.SAVE) { 40 | storage.saveTask(taskManagerTask); 41 | } else if (persistAction == PersistAction.DELETE) { 42 | storage.deleteTask(taskManagerTask); 43 | } 44 | } 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | } 49 | 50 | @Override 51 | public void runTask(PersistTask task) { 52 | throw new UnsupportedOperationException(); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandCancelPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMeta; 23 | import de.czymm.serversigns.meta.SVSMetaKey; 24 | import de.czymm.serversigns.meta.SVSMetaManager; 25 | import de.czymm.serversigns.meta.SVSMetaValue; 26 | import de.czymm.serversigns.translations.Message; 27 | 28 | public class SubCommandCancelPermission extends SubCommand { 29 | public SubCommandCancelPermission(ServerSignsPlugin plugin) { 30 | super( 31 | plugin, 32 | "cancel_permission", 33 | "cancelpermission [message]", 34 | "Users with this permission will not be able to execute the ServerSign", 35 | "cancelpermission", "canpermission", "canperm", "cancelperm", "cperm", "cpermission" 36 | ); 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | if (!argSet(0)) { 42 | if (verbose) sendUsage(); 43 | return; 44 | } 45 | 46 | SVSMeta meta = new SVSMeta(SVSMetaKey.CANCEL_PERMISSION, new SVSMetaValue(arg(0))); 47 | if (argSet(1)) { 48 | meta.addValue(new SVSMetaValue(loopArgs(1))); 49 | } 50 | 51 | SVSMetaManager.setMeta(player, meta); 52 | if (verbose) msg(Message.RIGHT_CLICK_BIND_CANCEL_PERMISSION); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/hooks/VaultHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.hooks; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import net.milkbowl.vault.economy.Economy; 22 | import net.milkbowl.vault.permission.Permission; 23 | import org.bukkit.plugin.RegisteredServiceProvider; 24 | 25 | public class VaultHook { 26 | 27 | protected ServerSignsPlugin plugin; 28 | 29 | private Economy economy = null; 30 | private Permission permission = null; 31 | 32 | public VaultHook(ServerSignsPlugin plugin) { 33 | this.plugin = plugin; 34 | 35 | RegisteredServiceProvider economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); 36 | if (economyProvider != null) { 37 | economy = economyProvider.getProvider(); 38 | } 39 | 40 | RegisteredServiceProvider permissionProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class); 41 | if (permissionProvider != null) { 42 | permission = permissionProvider.getProvider(); 43 | } 44 | } 45 | 46 | public Economy getEconomy() { 47 | return economy; 48 | } 49 | 50 | public Permission getPermission() { 51 | return permission; 52 | } 53 | 54 | public boolean hasEconomy() { 55 | return economy != null; 56 | } 57 | 58 | public boolean hasPermissions() { 59 | return permission != null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.Material; 21 | import org.bukkit.inventory.ItemStack; 22 | import org.bukkit.inventory.meta.ItemMeta; 23 | 24 | public class ItemType extends ItemData implements IItemData { 25 | private static ItemType i = new ItemType(); 26 | 27 | public static ItemType get() { 28 | return i; 29 | } 30 | 31 | public ItemType() { 32 | super(ItemPart.TYPE, new String[]{"id.", "type.", "identity.", "item."}); 33 | } 34 | 35 | @SuppressWarnings("deprecation") 36 | @Override 37 | public ItemStack applyValue(ItemStack item, String value) throws DataException { 38 | Material mat = Material.getMaterial(value); 39 | if (mat == null) { 40 | try { 41 | mat = Material.getMaterial(Integer.parseInt(value)); 42 | } catch (NumberFormatException ex) { 43 | return null; 44 | } // Can't make an item without an ID! 45 | } 46 | if (mat == null) { 47 | throw new DataException(value + " is not a valid ItemStack type!"); 48 | } 49 | 50 | if (item != null) { 51 | item.setType(mat); 52 | return item; 53 | } 54 | 55 | return new ItemStack(mat); 56 | } 57 | 58 | @Override 59 | public ItemMeta applyMetaValue(ItemMeta item, String value) throws DataException { 60 | throw new UnsupportedOperationException(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/itemdata/ItemSearchCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.itemdata; 19 | 20 | import org.bukkit.ChatColor; 21 | 22 | import java.io.Serializable; 23 | 24 | public class ItemSearchCriteria implements Serializable { 25 | 26 | private boolean ignoreEnchants; 27 | private boolean ignoreName; 28 | private boolean ignoreLore; 29 | private boolean ignoreDurability; 30 | 31 | public ItemSearchCriteria(boolean ignoreEnchants, boolean ignoreName, boolean ignoreLore, boolean ignoreDurability) { 32 | this.ignoreEnchants = ignoreEnchants; 33 | this.ignoreName = ignoreName; 34 | this.ignoreLore = ignoreLore; 35 | this.ignoreDurability = ignoreDurability; 36 | } 37 | 38 | public boolean getEnchantsCriteria() { 39 | return ignoreEnchants; 40 | } 41 | 42 | public boolean getIgnoreName() { 43 | return ignoreName; 44 | } 45 | 46 | public boolean getIgnoreLore() { 47 | return ignoreLore; 48 | } 49 | 50 | public boolean getIgnoreDurability() { 51 | return ignoreDurability; 52 | } 53 | 54 | public String getColouredString(ChatColor tru, ChatColor fals) { 55 | return ((ignoreEnchants ? tru + "Enchants " : fals + "Enchants ") + 56 | (ignoreName ? tru + "Name " : fals + "Name ") + 57 | (ignoreLore ? tru + "Lores " : fals + "Lores ") + 58 | (ignoreDurability ? tru + "Durability " : fals + "Durability ")) 59 | .trim(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/utils/BlockUtils.java: -------------------------------------------------------------------------------- 1 | package de.czymm.serversigns.utils; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.block.BlockState; 5 | import org.bukkit.material.Door; 6 | 7 | import java.lang.reflect.InvocationTargetException; 8 | 9 | public class BlockUtils { 10 | 11 | public static boolean isDoor(final Block block) { 12 | return (isOld()) ? old_isDoor(block.getState()) : latest_isDoor(block.getState()); 13 | } 14 | 15 | public static boolean isTopHalf(final Block block) { 16 | return (isOld()) ? old_isTopHalf(block.getState()) : latest_isTopHalf(block.getState()); 17 | } 18 | 19 | private static boolean isOld() { 20 | return Version.isLowerOrEqualsTo(Version.V1_12); 21 | } 22 | 23 | public static boolean old_isTopHalf(final BlockState state) { 24 | return old_isDoor(state) && ((Door) state.getData()).isTopHalf(); 25 | } 26 | 27 | public static boolean latest_isTopHalf(final BlockState state) { 28 | if (latest_isDoor(state)) { 29 | try { 30 | final Object data = state.getClass().getMethod("getBlockData").invoke(state); 31 | final Class half = Class.forName("org.bukkit.block.data.Bisected$Half"); 32 | final Object enumValue = Enum.valueOf(half, "TOP"); 33 | 34 | return (data.getClass().getMethod("getHalf").invoke(data) == enumValue); 35 | } catch(NoSuchMethodException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | return false; 40 | } 41 | 42 | public static boolean old_isDoor(final BlockState state) { 43 | return state.getData() instanceof Door; 44 | } 45 | 46 | public static boolean latest_isDoor(final BlockState state) { 47 | try { 48 | final Object data = state.getClass().getMethod("getBlockData").invoke(state); 49 | final Class door = Class.forName("org.bukkit.block.data.type.Door"); 50 | 51 | return door.isInstance(data); 52 | } catch(NoSuchMethodException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e) { 53 | e.printStackTrace(); 54 | } 55 | return false; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/RandomOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import de.czymm.serversigns.utils.NumberUtils; 23 | import org.bukkit.entity.Player; 24 | 25 | import java.util.Random; 26 | 27 | public class RandomOperator extends ConditionalOperator { 28 | 29 | private static final Random RANDOM = new Random(); 30 | 31 | public RandomOperator() { 32 | super("random", true); 33 | } 34 | 35 | @Override 36 | public ParameterValidityResponse checkParameterValidity(String params) { 37 | if (!params.endsWith("%")) { 38 | return new ParameterValidityResponse(false, "Parameter must be a percentage"); 39 | } 40 | 41 | String value = params.substring(0, params.length() - 1); 42 | if (!NumberUtils.isDouble(value)) { 43 | return new ParameterValidityResponse(false, "Parameter must be a numeral percentage such as 25% or 0.01%"); 44 | } 45 | 46 | return new ParameterValidityResponse(true); 47 | } 48 | 49 | @Override 50 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 51 | if (params == null) { 52 | return false; 53 | } 54 | 55 | double percentChance = NumberUtils.parseDouble(params.substring(0, params.length() - 1)); 56 | return RANDOM.nextDouble() < (percentChance / 100); // Normalise % to < 1.0 equivalent 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandHeldItemCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandHeldItemCriteria extends SubCommand { 27 | public SubCommandHeldItemCriteria(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "held_item_criteria", 31 | "hic ", 32 | "Set whether the listed item attributes should be ignored in held item checks on an existing ServerSign (true/false)", 33 | "hic", "helditemcriteria", "holditemcriteria", "holdcriteria" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | if (!argSet(3)) { 40 | if (verbose) sendUsage(); 41 | return; 42 | } 43 | 44 | // Sample 45 | if (!arg(0).equalsIgnoreCase("true") && !arg(1).equalsIgnoreCase("false")) { 46 | if (verbose) msg(Message.ITEM_CRITERIA_BOOLEAN); 47 | return; 48 | } 49 | 50 | applyMeta(SVSMetaKey.HELD_ITEM_CRITERIA, new SVSMetaValue(argBool(0, true)), new SVSMetaValue(argBool(1, true)), new SVSMetaValue(argBool(2, true)), new SVSMetaValue(argBool(3, true))); 51 | if (verbose) msg(Message.HELD_ITEM_CRITERIA_BIND); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandPriceItemCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | public class SubCommandPriceItemCriteria extends SubCommand { 27 | public SubCommandPriceItemCriteria(ServerSignsPlugin plugin) { 28 | super( 29 | plugin, 30 | "price_item_criteria", 31 | "pic ", 32 | "Set whether the listed item attributes should be ignored in price item checks on an existing ServerSign (true/false)", 33 | "pic", "priceitemcriteria", "priceitemcrit", "picrit", "picriteria" 34 | ); 35 | } 36 | 37 | @Override 38 | public void execute(boolean verbose) { 39 | if (!argSet(3)) { 40 | if (verbose) sendUsage(); 41 | return; 42 | } 43 | 44 | // Sample 45 | if (!arg(0).equalsIgnoreCase("true") && !arg(0).equalsIgnoreCase("false")) { 46 | if (verbose) msg(Message.ITEM_CRITERIA_BOOLEAN); 47 | return; 48 | } 49 | 50 | applyMeta(SVSMetaKey.PRICE_ITEM_CRITERIA, new SVSMetaValue(argBool(0, true)), new SVSMetaValue(argBool(1, true)), new SVSMetaValue(argBool(2, true)), new SVSMetaValue(argBool(3, true))); 51 | if (verbose) msg(Message.PRICE_ITEM_CRITERIA_BIND); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PermissionGrantPlayerTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import org.bukkit.entity.Player; 22 | 23 | import java.util.UUID; 24 | 25 | public class PermissionGrantPlayerTask extends PlayerTask { 26 | private boolean permissionChanged; 27 | 28 | public PermissionGrantPlayerTask(long runAt, String action, UUID playerUniqueId, boolean alwaysPersisted) { 29 | super(runAt, PermissionGrantPlayerTaskType.PERMISSION_GRANT, action, playerUniqueId, alwaysPersisted); 30 | } 31 | 32 | protected PermissionGrantPlayerTask(long taskID, long runAt, String action, UUID playerUniqueId, boolean alwaysPersisted) { 33 | super(taskID, runAt, PermissionGrantPlayerTaskType.PERMISSION_GRANT, action, playerUniqueId, alwaysPersisted); 34 | } 35 | 36 | @Override 37 | public TaskType getTaskType() { 38 | return TaskType.PERMISSION_GRANT; 39 | } 40 | 41 | public boolean isPermissionChanged() { 42 | return permissionChanged; 43 | } 44 | 45 | @Override 46 | protected TaskStatus runPlayerTask(ServerSignsPlugin plugin, Player player) { 47 | if (plugin.hookManager.vault.isHooked() && plugin.hookManager.vault.getHook().hasPermissions()) { 48 | if (!player.hasPermission(getData())) { 49 | plugin.hookManager.vault.getHook().getPermission().playerAdd(player, getData()); 50 | permissionChanged = true; 51 | } 52 | } 53 | return TaskStatus.SUCCESS; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/PlayerTaskSaver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | import de.czymm.serversigns.taskmanager.tasks.PlayerTask; 22 | 23 | import java.sql.Connection; 24 | import java.sql.PreparedStatement; 25 | import java.sql.SQLException; 26 | import java.util.List; 27 | 28 | public class PlayerTaskSaver implements ISQLiteTaskSaver { 29 | private static final String SQL_INSERT_PLAYER_TASK = "INSERT INTO PlayerTask (TaskId, PlayerUniqueId)\n" + 30 | "VALUES (?, ?)"; 31 | private final TaskSaver taskSaver; 32 | private PreparedStatement statement; 33 | 34 | public PlayerTaskSaver(TaskSaver taskSaver) { 35 | this.taskSaver = taskSaver; 36 | } 37 | 38 | @Override 39 | public void saveTask(Connection connection, TaskManagerTask task, List closeChain) throws SQLException { 40 | PlayerTask playerTask = ((PlayerTask) task); 41 | taskSaver.saveTask(connection, task, closeChain); 42 | 43 | if (statement == null) { 44 | statement = connection.prepareStatement(SQL_INSERT_PLAYER_TASK); 45 | closeChain.add(this); 46 | } 47 | 48 | statement.setLong(1, playerTask.getTaskID()); 49 | statement.setString(2, playerTask.getPlayerUniqueId().toString()); 50 | statement.execute(); 51 | } 52 | 53 | @Override 54 | public void close() throws SQLException { 55 | try { 56 | statement.close(); 57 | } finally { 58 | statement = null; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PlayerTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 22 | import org.bukkit.Bukkit; 23 | import org.bukkit.entity.Player; 24 | 25 | import java.util.UUID; 26 | 27 | public abstract class PlayerTask> extends TaskManagerTask { 28 | private final UUID playerUniqueId; 29 | 30 | public PlayerTask(long runAt, T actionType, String action, UUID playerUniqueId, boolean alwaysPersisted) { 31 | super(runAt, actionType, action, alwaysPersisted); 32 | this.playerUniqueId = playerUniqueId; 33 | } 34 | 35 | protected PlayerTask(long taskID, long runAt, T type, String action, UUID playerUniqueId, boolean alwaysPersisted) { 36 | super(taskID, runAt, type, action, alwaysPersisted); 37 | this.playerUniqueId = playerUniqueId; 38 | } 39 | 40 | public UUID getPlayerUniqueId() { 41 | return playerUniqueId; 42 | } 43 | 44 | @Override 45 | public TaskStatus runTask(ServerSignsPlugin plugin) { 46 | Player player = Bukkit.getPlayer(getPlayerUniqueId()); 47 | if (player == null) { 48 | return TaskStatus.PLAYER_NOT_ONLINE; 49 | } 50 | 51 | return runPlayerTask(plugin, player); 52 | } 53 | 54 | protected abstract TaskStatus runPlayerTask(ServerSignsPlugin plugin, Player player); 55 | 56 | @Override 57 | public String toString() { 58 | return "PlayerTask{" + 59 | "data='" + getData() + '\'' + 60 | "} " + super.toString(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/de/czymm/serversigns/taskmanager/QueueConsumerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager; 19 | 20 | import org.junit.Before; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.mockito.ArgumentMatcher; 24 | import org.mockito.runners.MockitoJUnitRunner; 25 | 26 | import java.util.List; 27 | import java.util.concurrent.BlockingQueue; 28 | import java.util.concurrent.LinkedBlockingQueue; 29 | 30 | import static org.mockito.Mockito.*; 31 | 32 | @RunWith(MockitoJUnitRunner.class) 33 | public class QueueConsumerTest { 34 | private BlockingQueue queue; 35 | private ITaskExecutor taskExecutor; 36 | private QueueConsumer queueConsumer; 37 | 38 | @Before 39 | @SuppressWarnings("unchecked") 40 | public void setUp() throws Exception { 41 | queue = new LinkedBlockingQueue<>(); 42 | taskExecutor = mock(ITaskExecutor.class); 43 | queueConsumer = spy(new QueueConsumer<>(queue, taskExecutor)); 44 | } 45 | 46 | @Test 47 | public void testRun() throws Exception { 48 | final Object o1 = new Object(); 49 | final Object o2 = new Object(); 50 | 51 | queue.offer(o1); 52 | queue.offer(o2); 53 | 54 | Thread thread = new Thread(queueConsumer); 55 | thread.start(); 56 | 57 | verify(taskExecutor, timeout(1000)).runTasks(argThat(new ArgumentMatcher>() { 58 | @Override 59 | public boolean matches(Object o) { 60 | List list = (List) o; 61 | return list.contains(o1) && list.contains(o2); 62 | } 63 | })); 64 | 65 | queueConsumer.stop(); 66 | thread.interrupt(); 67 | } 68 | } -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/utils/Version.java: -------------------------------------------------------------------------------- 1 | package de.czymm.serversigns.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public enum Version { 7 | CURRENT(0, 0), 8 | V1_7(1, 7), 9 | V1_8(1, 8), 10 | V1_9(1, 9), 11 | V1_10(1, 10), 12 | V1_11(1, 11), 13 | V1_12(1, 12), 14 | V1_13(1, 13), 15 | V1_14(1, 14), 16 | V1_15(1, 15), 17 | V1_16(1, 16), 18 | V1_17(1, 17), 19 | V1_18(1, 18), 20 | V1_19(1, 19), 21 | V1_20(1, 20), 22 | V1_21(1, 21); 23 | 24 | private int major; 25 | private int minor; 26 | 27 | private static final Pattern versionRegex = Pattern.compile("(\\d+)[.](\\d+)"); 28 | 29 | Version(final int major, final int minor) { 30 | this.major = major; 31 | this.minor = minor; 32 | } 33 | 34 | private void updateVersion(final String strVersion) { 35 | final Matcher matcher = versionRegex.matcher(strVersion); 36 | 37 | if (matcher.find() && matcher.groupCount() >= 2) { 38 | major = Integer.parseInt(matcher.group(1)); 39 | minor = Integer.parseInt(matcher.group(2)); 40 | } 41 | } 42 | 43 | public static void initVersion(final String strVersion) { 44 | Version.CURRENT.updateVersion(strVersion); 45 | } 46 | 47 | public static boolean isLowerThan(final Version newVersion) { 48 | return (CURRENT.minor < newVersion.minor && CURRENT.major == newVersion.major) || CURRENT.major < newVersion.major; 49 | } 50 | 51 | public static boolean isLowerOrEqualsTo(final Version newVersion) { 52 | return (CURRENT.minor == newVersion.minor && CURRENT.major == newVersion.major) || 53 | ((CURRENT.minor < newVersion.minor && CURRENT.major == newVersion.major) || CURRENT.major < newVersion.major); 54 | } 55 | 56 | public static boolean isEqualsTo(final Version newVersion) { 57 | return CURRENT.minor == newVersion.minor && CURRENT.major == newVersion.major; 58 | } 59 | 60 | public static boolean isHigherOrEqualsTo(final Version newVersion) { 61 | return (CURRENT.minor == newVersion.minor && CURRENT.major == newVersion.major) || 62 | ((CURRENT.minor > newVersion.minor && CURRENT.major == newVersion.major) || CURRENT.major > newVersion.major); 63 | } 64 | 65 | public static boolean isHigherThan(final Version newVersion) { 66 | return (CURRENT.minor > newVersion.minor && CURRENT.major == newVersion.major) || CURRENT.major > newVersion.major; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/HasBalanceOperator.java: -------------------------------------------------------------------------------- 1 | package de.czymm.serversigns.parsing.operators; 2 | 3 | import de.czymm.serversigns.ServerSignsPlugin; 4 | import de.czymm.serversigns.signs.ServerSign; 5 | import de.czymm.serversigns.utils.NumberUtils; 6 | import org.bukkit.entity.Player; 7 | 8 | public class HasBalanceOperator extends ConditionalOperator { 9 | 10 | public HasBalanceOperator() { 11 | super("hasBalance", true); 12 | } 13 | 14 | @Override 15 | public ParameterValidityResponse checkParameterValidity(String params) { 16 | 17 | char operatorChar = getOperatorChar(params); 18 | if (operatorChar == '¬') { 19 | return new ParameterValidityResponse(false, "Parameter must be in the format - where is > < or ="); 20 | } 21 | 22 | String amountStr = params.substring(1); 23 | 24 | if (!NumberUtils.isDouble(amountStr)) { 25 | return new ParameterValidityResponse(false, "Parameter must be in the format - where is a decimal number or integer"); 26 | } 27 | 28 | return new ParameterValidityResponse(true); 29 | } 30 | 31 | @Override 32 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 33 | if (params == null) { 34 | return false; 35 | } 36 | 37 | if (!plugin.hookManager.vault.isHooked() || !plugin.hookManager.vault.getHook().hasEconomy()) { 38 | return false; 39 | } 40 | 41 | char operatorChar = getOperatorChar(params); 42 | int amount = NumberUtils.parseInt(params.substring(1)); 43 | 44 | switch (operatorChar) { 45 | case '>': 46 | return plugin.hookManager.vault.getHook().getEconomy().getBalance(executor) > amount; 47 | 48 | case '<': 49 | return plugin.hookManager.vault.getHook().getEconomy().getBalance(executor) < amount; 50 | 51 | case '=': 52 | return plugin.hookManager.vault.getHook().getEconomy().getBalance(executor) == amount; 53 | 54 | default: 55 | return false; 56 | } 57 | } 58 | 59 | private char getOperatorChar(String params) { 60 | switch (params.charAt(0)) { 61 | case '>': 62 | case '<': 63 | case '=': 64 | return params.charAt(0); 65 | default: 66 | return '¬'; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandCopy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMeta; 23 | import de.czymm.serversigns.meta.SVSMetaKey; 24 | import de.czymm.serversigns.meta.SVSMetaManager; 25 | import de.czymm.serversigns.meta.SVSMetaValue; 26 | import de.czymm.serversigns.translations.Message; 27 | 28 | public class SubCommandCopy extends SubCommand { 29 | public SubCommandCopy(ServerSignsPlugin plugin) { 30 | super( 31 | plugin, 32 | "copy", 33 | "copy [persist]", 34 | "Copy and paste a ServerSign", 35 | "copy", "cp" 36 | ); 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | if (argSet(0) && !arg(0).equalsIgnoreCase("true") && !arg(0).equalsIgnoreCase("false")) { 42 | if (verbose) sendUsage(); 43 | return; 44 | } 45 | 46 | if (argSet(0) && arg(0).equalsIgnoreCase("false")) { 47 | if (SVSMetaManager.hasMeta(player)) { 48 | SVSMeta meta = SVSMetaManager.getMeta(player); 49 | if (meta.getValue().asBoolean()) // Persistence is currently on, disable it! 50 | { 51 | SVSMetaManager.removeMeta(player); 52 | if (verbose) msg(Message.PERSISTENCE_OFF); 53 | return; 54 | } 55 | } 56 | } 57 | 58 | applyMeta(SVSMetaKey.COPY, new SVSMetaValue(argSet(0) ? argBool(0) : false)); 59 | if (argSet(0) && argBool(0) && verbose) msg(Message.PERSISTENCE_ON); 60 | if (verbose) msg(Message.RIGHT_CLICK_COPY); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandDev.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.legacy.ServerSignConverter; 23 | import org.bukkit.entity.Player; 24 | 25 | public class SubCommandDev extends SubCommand { 26 | public SubCommandDev(ServerSignsPlugin plugin) { 27 | super( 28 | plugin, 29 | "", 30 | "dev ", 31 | "This command is intended for advanced users only; no documentation is provided.", 32 | "dev" 33 | ); 34 | } 35 | 36 | @Override 37 | public void execute(boolean verbose) { 38 | if (!argSet(0)) { 39 | if (verbose) sendUsage(); 40 | return; 41 | } 42 | 43 | if (argStr(0).equalsIgnoreCase("total")) { 44 | sender.sendMessage("Total number of ServerSigns loaded: " + plugin.serverSignsManager.getSigns().size()); 45 | return; 46 | } 47 | 48 | if (argStr(0).equalsIgnoreCase("persist_version")) { 49 | sender.sendMessage("Current persistence version: " + ServerSignConverter.FILE_VERSION); 50 | return; 51 | } 52 | 53 | if (argStr(0).equalsIgnoreCase("hooks")) { 54 | sender.sendMessage(String.format("Vault: %b, NCP: %b, Ess: %b, PAPI: %b", plugin.hookManager.vault.isHooked(), plugin.hookManager.noCheatPlus.isHooked(), plugin.hookManager.essentials.isHooked(), plugin.hookManager.placeholderAPI.isHooked())); 55 | return; 56 | } 57 | 58 | if (verbose) sendUsage(); 59 | } 60 | 61 | @Override 62 | public boolean hasPermission(Player player) { 63 | return player.isOp(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMeta; 23 | import de.czymm.serversigns.meta.SVSMetaKey; 24 | import de.czymm.serversigns.meta.SVSMetaManager; 25 | import de.czymm.serversigns.meta.SVSMetaValue; 26 | import de.czymm.serversigns.translations.Message; 27 | 28 | public class SubCommandList extends SubCommand { 29 | public SubCommandList(ServerSignsPlugin plugin) { 30 | super( 31 | plugin, 32 | "list", 33 | "list [persist]", 34 | "List all information available for an existing ServerSign", 35 | "list", "ls", "info" 36 | ); 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | if (argSet(0) && !arg(0).equalsIgnoreCase("true") && !arg(0).equalsIgnoreCase("false")) { 42 | if (verbose) sendUsage(); 43 | return; 44 | } 45 | 46 | if (argSet(0) && arg(0).equalsIgnoreCase("false")) { 47 | if (SVSMetaManager.hasMeta(player)) { 48 | SVSMeta meta = SVSMetaManager.getMeta(player); 49 | if (meta.getValue().asBoolean()) // Persistence is currently on, disable it! 50 | { 51 | SVSMetaManager.removeMeta(player); 52 | if (verbose) msg(Message.LIST_PERSIST_OFF); 53 | return; 54 | } 55 | } 56 | } 57 | 58 | applyMeta(SVSMetaKey.LIST, new SVSMetaValue(argBool(0, false))); 59 | if (argSet(0) && argBool(0, false) && verbose) msg(Message.LIST_PERSIST_ON); 60 | if (verbose) msg(Message.RIGHT_CLICK_VIEW_LIST); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/datastorage/SQLiteDataStorageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.datastorage; 19 | 20 | import de.czymm.serversigns.taskmanager.QueueConsumer; 21 | 22 | import java.nio.file.Path; 23 | import java.util.concurrent.BlockingQueue; 24 | import java.util.concurrent.LinkedBlockingQueue; 25 | 26 | public class SQLiteDataStorageHandler implements IDataStorageHandler { 27 | private final QueueConsumer queueConsumer; 28 | private final String databaseUrl; 29 | private final BlockingQueue tasksQueue; 30 | 31 | public SQLiteDataStorageHandler(Path dataFolder) throws ClassNotFoundException { 32 | Class.forName("org.sqlite.JDBC"); 33 | databaseUrl = String.format("jdbc:sqlite:%s", dataFolder.resolve("tasks.sqlite").toString()); 34 | tasksQueue = new LinkedBlockingQueue<>(); 35 | PersistTaskExecutor persistTaskExecutor = new PersistTaskExecutor(this); 36 | queueConsumer = new QueueConsumer<>(tasksQueue, persistTaskExecutor); 37 | } 38 | 39 | @Override 40 | public void init() throws Exception { 41 | try (IDataStorageAccessor storage = new SQLiteDataStorageAccessor(databaseUrl)) { 42 | storage.prepareDataStructure(); 43 | } 44 | Thread persistThread = new Thread(queueConsumer, "ServerSigns-TaskPersistence"); 45 | persistThread.start(); 46 | } 47 | 48 | @Override 49 | public IDataStorageAccessor newDataStorageAccessor() throws Exception { 50 | return new SQLiteDataStorageAccessor(databaseUrl); 51 | } 52 | 53 | @Override 54 | public void addTask(PersistTask task) { 55 | tasksQueue.offer(task); 56 | } 57 | 58 | @Override 59 | public void close() { 60 | queueConsumer.stop(); 61 | tasksQueue.add(new PersistTask(PersistAction.STOP, null)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/operators/OnlinePlayersOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.operators; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.signs.ServerSign; 22 | import de.czymm.serversigns.utils.NumberUtils; 23 | import org.bukkit.entity.Player; 24 | 25 | public class OnlinePlayersOperator extends ConditionalOperator { 26 | 27 | public OnlinePlayersOperator() { 28 | super("onlinePlayers", true); 29 | } 30 | 31 | @Override 32 | public ParameterValidityResponse checkParameterValidity(String params) { 33 | char firstChar = params.charAt(0); 34 | if (firstChar != '>' && firstChar != '<' && firstChar != '=') { 35 | return new ParameterValidityResponse(false, "Parameter must start with > < or ="); 36 | } 37 | 38 | String value = params.substring(1); 39 | if (!NumberUtils.isInt(value)) { 40 | return new ParameterValidityResponse(false, "Parameter must be an integer preceded by > < or ="); 41 | } 42 | 43 | return new ParameterValidityResponse(true); 44 | } 45 | 46 | @Override 47 | public boolean meetsConditions(Player executor, ServerSign executingSign, ServerSignsPlugin plugin) { 48 | if (params == null) { 49 | return false; 50 | } 51 | 52 | int onlinePlayers = plugin.getServer().getOnlinePlayers().size(); 53 | 54 | char firstChar = params.charAt(0); 55 | int value = NumberUtils.parseInt(params.substring(1)); 56 | switch (firstChar) { 57 | case '>': 58 | return onlinePlayers > value; 59 | case '<': 60 | return onlinePlayers < value; 61 | case '=': 62 | return onlinePlayers == value; 63 | default: 64 | return false; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/ItemStackListMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.itemdata.ItemStringParser; 22 | import de.czymm.serversigns.utils.ItemUtils; 23 | import org.bukkit.configuration.MemorySection; 24 | import org.bukkit.inventory.ItemStack; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | 29 | public class ItemStackListMapper implements ISmartPersistenceMapper> { 30 | private MemorySection memorySection; 31 | private String host = "unknown"; 32 | 33 | @Override 34 | public void setMemorySection(MemorySection memorySection) { 35 | this.memorySection = memorySection; 36 | } 37 | 38 | @Override 39 | public List getValue(String path) { 40 | ArrayList stacks = new ArrayList<>(); 41 | List rawStrings = memorySection.getStringList(path); 42 | 43 | for (String raw : rawStrings) { 44 | ItemStringParser parser = new ItemStringParser(raw); 45 | ItemStack stack = parser.parse(); 46 | if (stack == null) continue; 47 | 48 | if (parser.encounteredErrors()) { 49 | ServerSignsPlugin.log("Encountered errors while building ItemStack from '" + host + "'"); 50 | } 51 | stacks.add(stack); 52 | } 53 | 54 | return stacks; 55 | } 56 | 57 | @Override 58 | public void setValue(String path, List val) { 59 | ArrayList list = new ArrayList<>(); 60 | for (ItemStack stack : val) { 61 | list.add(ItemUtils.getStringFromItemStack(stack)); 62 | } 63 | 64 | memorySection.set(path, list); 65 | } 66 | 67 | @Override 68 | public void setHostId(String id) { 69 | host = id; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/taskmanager/tasks/PermissionRemovePlayerTaskLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.taskmanager.tasks; 19 | 20 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 21 | import de.czymm.serversigns.taskmanager.datastorage.ISQLiteTaskLoader; 22 | 23 | import java.sql.ResultSet; 24 | import java.sql.SQLException; 25 | import java.util.Map; 26 | import java.util.UUID; 27 | 28 | public class PermissionRemovePlayerTaskLoader implements ISQLiteTaskLoader { 29 | @Override 30 | public PermissionRemovePlayerTask getTaskFromCurrentRow(ResultSet resultSet, Map loadedTasks) throws SQLException { 31 | PermissionRemovePlayerTaskType subType = PermissionRemovePlayerTaskType.valueOf(resultSet.getString(4)); 32 | switch (subType) { 33 | case PERMISSION_REMOVE: 34 | return new PermissionRemovePlayerTask( 35 | resultSet.getLong(1), 36 | resultSet.getLong(2), 37 | resultSet.getString(5), 38 | UUID.fromString(resultSet.getString(6)), 39 | true); 40 | case PERMISSION_GRANT_REMOVE: 41 | long grantTaskId = Long.parseLong(resultSet.getString(5)); 42 | TaskManagerTask grantTask = loadedTasks.get(grantTaskId); 43 | if (grantTask != null && grantTask instanceof PermissionGrantPlayerTask) { 44 | return new PermissionRemovePlayerTask( 45 | resultSet.getLong(1), 46 | resultSet.getLong(2), 47 | UUID.fromString(resultSet.getString(6)), 48 | ((PermissionGrantPlayerTask) grantTask), 49 | true); 50 | } 51 | } 52 | 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/persist/mapping/BlocksMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.persist.mapping; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import org.bukkit.Material; 22 | import org.bukkit.configuration.MemorySection; 23 | 24 | import java.util.ArrayList; 25 | import java.util.EnumSet; 26 | import java.util.List; 27 | import java.util.logging.Level; 28 | 29 | public class BlocksMapper implements IPersistenceMapper> { 30 | private MemorySection memorySection; 31 | 32 | @Override 33 | public void setMemorySection(MemorySection memorySection) { 34 | this.memorySection = memorySection; 35 | } 36 | 37 | @Override 38 | public EnumSet getValue(String path) { 39 | List unknownMaterials = new ArrayList<>(); 40 | List blocksList = memorySection.getStringList(path); 41 | EnumSet blocks = EnumSet.noneOf(Material.class); 42 | 43 | for (String block : blocksList) { 44 | Material material = Material.getMaterial(block); 45 | if (material != null) { 46 | blocks.add(material); 47 | } else { 48 | unknownMaterials.add(block); 49 | } 50 | } 51 | 52 | if (!unknownMaterials.isEmpty()) { 53 | ServerSignsPlugin.log("Unknown blocks : " + String.join(", ", unknownMaterials), Level.WARNING); 54 | ServerSignsPlugin.log("Please visit the wiki : https://serversigns.de/wiki/Configuration", Level.WARNING); 55 | } 56 | 57 | return blocks; 58 | } 59 | 60 | @Override 61 | public void setValue(String path, EnumSet val) { 62 | ArrayList list = new ArrayList<>(); 63 | for (Object material : val) { 64 | list.add(material.toString()); 65 | } 66 | 67 | memorySection.set(path, list); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandImport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMetaKey; 23 | import de.czymm.serversigns.meta.SVSMetaValue; 24 | import de.czymm.serversigns.translations.Message; 25 | 26 | import java.nio.file.Files; 27 | import java.nio.file.Path; 28 | import java.nio.file.Paths; 29 | 30 | public class SubCommandImport extends SubCommand { 31 | public SubCommandImport(ServerSignsPlugin plugin) { 32 | super( 33 | plugin, 34 | "import", 35 | "import ", 36 | "Import a text file of commands, 1 command per line without /svs", 37 | "import", "imp" 38 | ); 39 | } 40 | 41 | @Override 42 | public void execute(boolean verbose) { 43 | if (!argSet(0)) { 44 | if (verbose) sendUsage(); 45 | return; 46 | } 47 | 48 | String path = loopArgs(0); 49 | final Path fullPath = Paths.get(plugin.getDataFolder().getAbsolutePath()).resolve(path).toAbsolutePath().normalize(); 50 | 51 | // Check if file exists and is not a folder 52 | if (!Files.exists(fullPath) || fullPath.toFile().isDirectory()) { 53 | if (verbose) msg(Message.IMPORT_FILE_NOT_FOUND); 54 | return; 55 | } 56 | 57 | // Check the path is not outside of plugin data folder (plugins/ServerSigns/) 58 | if (!fullPath.toString().endsWith(".txt") || !fullPath.startsWith(plugin.getDataFolder().getAbsolutePath())) { 59 | if (verbose) msg(Message.INVALID_FILE_PATH); 60 | return; 61 | } 62 | 63 | if (verbose) msg(Message.IMPORT_SELECT_SIGN); 64 | applyMeta(SVSMetaKey.IMPORT, new SVSMetaValue(path)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/commands/SubCommandGrantPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.commands; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.commands.core.SubCommand; 22 | import de.czymm.serversigns.meta.SVSMeta; 23 | import de.czymm.serversigns.meta.SVSMetaKey; 24 | import de.czymm.serversigns.meta.SVSMetaManager; 25 | import de.czymm.serversigns.meta.SVSMetaValue; 26 | import de.czymm.serversigns.translations.Message; 27 | 28 | public class SubCommandGrantPermission extends SubCommand { 29 | public SubCommandGrantPermission(ServerSignsPlugin plugin) { 30 | super( 31 | plugin, 32 | "grant", 33 | "grant {delete | add} [permission]", 34 | "Add or remove a granted permission to/from an existing ServerSign", 35 | "permissiongrant", "permissionsgrant", "pgrant", "grantpermission", "grantpermissions", "grant" 36 | ); 37 | } 38 | 39 | @Override 40 | public void execute(boolean verbose) { 41 | if (!argSet(0)) { 42 | if (verbose) sendUsage(); 43 | return; 44 | } 45 | 46 | SVSMeta meta; 47 | if (arg(0).equalsIgnoreCase("delete")) { 48 | meta = new SVSMeta(SVSMetaKey.GRANT, new SVSMetaValue(false)); 49 | if (verbose) msg(Message.RIGHT_CLICK_DEL_PERMISSION); 50 | } else if (arg(0).equalsIgnoreCase("add")) { 51 | if (!argSet(1)) { 52 | if (verbose) sendUsage(); 53 | return; 54 | } 55 | 56 | meta = new SVSMeta(SVSMetaKey.GRANT, new SVSMetaValue(true), new SVSMetaValue(arg(1))); 57 | if (verbose) msg(Message.RIGHT_CLICK_BIND_PERMISSION); 58 | } else { 59 | if (verbose) sendUsage(); 60 | return; 61 | } 62 | 63 | SVSMetaManager.setMeta(player, meta); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/de/czymm/serversigns/parsing/command/ReturnServerSignCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ServerSigns. 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package de.czymm.serversigns.parsing.command; 19 | 20 | import de.czymm.serversigns.ServerSignsPlugin; 21 | import de.czymm.serversigns.parsing.CommandType; 22 | import de.czymm.serversigns.taskmanager.TaskManagerTask; 23 | import org.bukkit.entity.Player; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | import java.util.Map; 28 | 29 | public class ReturnServerSignCommand extends ServerSignCommand { 30 | 31 | public ReturnServerSignCommand() { 32 | super(CommandType.RETURN, ""); 33 | } 34 | 35 | // Overrides 36 | 37 | @Override 38 | public boolean isAlwaysPersisted() { 39 | return false; 40 | } 41 | 42 | @Override 43 | public void setAlwaysPersisted(boolean val) { 44 | // Do nothing 45 | } 46 | 47 | @Override 48 | public CommandType getType() { 49 | return type; 50 | } 51 | 52 | @Override 53 | public List getGrantPermissions() { 54 | return new ArrayList<>(); 55 | } 56 | 57 | @Override 58 | public long getDelay() { 59 | return 0; 60 | } 61 | 62 | @Override 63 | public void setDelay(long delay) { 64 | // Do nothing 65 | } 66 | 67 | @Override 68 | public void setGrantPermissions(List grant) { 69 | // Do nothing 70 | } 71 | 72 | @Override 73 | public String getUnformattedCommand() { 74 | return command; 75 | } 76 | 77 | @Override 78 | public String getFormattedCommand(Player executor, ServerSignsPlugin plugin, Map injectedReplacements) { 79 | return command; 80 | } 81 | 82 | @Override 83 | public List getTasks(Player executor, ServerSignsPlugin plugin, Map injectedReplacements) { 84 | return new ArrayList<>(); // No tasks to be executed for a halt command 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ServerSigns 2 | main: de.czymm.serversigns.ServerSignsPlugin 3 | version: ${version} 4 | api-version: 1.13 5 | authors: [CalibeR50, Exloki] 6 | softdepend: [Vault, NoCheatPlus, Essentials, PlaceholderAPI] 7 | load: POSTWORLD 8 | description: > 9 | ServerSigns 10 | commands: 11 | 12 | serversigns: 13 | description: The main ServerSigns plugin command 14 | aliases: svs 15 | usage: / 16 | 17 | serversignsremote: 18 | description: Allows remote modification of ServerSigns 19 | aliases: svsr 20 | usage: / 21 | 22 | permissions: 23 | 24 | serversigns.admin: 25 | description: Gives access to all ServerSigns commands 26 | default: op 27 | children: 28 | serversigns.command.add: true 29 | serversigns.command.set_cancel: true 30 | serversigns.command.cancel_permission: true 31 | serversigns.command.confirmation: true 32 | serversigns.command.copy: true 33 | serversigns.command.create: true 34 | serversigns.command.edit: true 35 | serversigns.command.grant: true 36 | serversigns.command.held_item_criteria: true 37 | serversigns.command.holding: true 38 | serversigns.command.import: true 39 | serversigns.command.insert: true 40 | serversigns.command.list: true 41 | serversigns.command.long: true 42 | serversigns.command.option: true 43 | serversigns.command.price_item: true 44 | serversigns.command.price_item_criteria: true 45 | serversigns.command.reload: true 46 | serversigns.command.reload_config: true 47 | serversigns.command.reload_signs: true 48 | serversigns.command.remove: true 49 | serversigns.command.reset_all_cooldowns: true 50 | serversigns.command.reset_cooldown: true 51 | serversigns.command.resetcooldowns: true 52 | serversigns.command.select: true 53 | serversigns.command.set_cooldown: true 54 | serversigns.command.set_global_cooldown: true 55 | serversigns.command.set_loops: true 56 | serversigns.command.set_permission: true 57 | serversigns.command.set_price: true 58 | serversigns.command.set_uses: true 59 | serversigns.command.silent: true 60 | serversigns.command.timelimit: true 61 | serversigns.command.void: true 62 | serversigns.command.xp: true 63 | 64 | serversigns.use: 65 | description: Allows you to use a ServerSign 66 | 67 | serversigns.updatenotification: 68 | default: op 69 | description: Allows you to see update notifications --------------------------------------------------------------------------------