Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yusshu committed Jul 31, 2023
0 parents commit bdb6b6c
Show file tree
Hide file tree
Showing 79 changed files with 4,157 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = false
indent_size = 4
indent_style = space

# intellij idea
ij_continuation_indent_size = 8
ij_java_do_not_wrap_after_single_annotation = true
ij_java_class_count_to_use_import_on_demand = 10
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'build'

on: [ 'push', 'pull_request' ]

jobs:
build:
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: 'ubuntu-latest'
steps:
- name: 'checkout repo'
uses: 'actions/checkout@v2'
- name: 'setup JDK 1.8'
uses: 'actions/setup-java@v1'
with:
java-version: 1.8
- name: 'build'
run: './gradlew build'
- name: 'publish'
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: './gradlew publish'
env:
ORG_GRADLE_PROJECT_unnamedRepositoryUsername: '${{ secrets.REPO_USER }}'
ORG_GRADLE_PROJECT_unnamedRepositoryPassword: '${{ secrets.REPO_PASSWORD }}'
88 changes: 88 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Gradle files
.gradle

# Output files
/build/
/*/build/

# Editors files
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Discord plugin
.idea/discord.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/copyright/creative_mit_license.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("creative.publishing-conventions")
}

dependencies {
api("team.unnamed:creative-api:$version")
api("net.kyori:adventure-api:4.13.1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of creative, licensed under the MIT license
*
* Copyright (c) 2021-2023 Unnamed Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package team.unnamed.creative.central;

import team.unnamed.creative.ResourcePack;
import team.unnamed.creative.central.event.EventBus;
import team.unnamed.creative.central.request.ResourcePackRequestSender;
import team.unnamed.creative.central.server.CentralResourcePackServer;
import team.unnamed.creative.central.server.ServeOptions;

import java.util.concurrent.CompletableFuture;

/**
* @since 1.0.0
*/
public interface CreativeCentral {

CentralResourcePackServer server();

ServeOptions serveOptions();

ResourcePackRequestSender requestSender();

EventBus eventBus();

CompletableFuture<ResourcePack> generate();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* This file is part of creative, licensed under the MIT license
*
* Copyright (c) 2021-2023 Unnamed Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package team.unnamed.creative.central;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import static java.util.Objects.requireNonNull;

/**
* Static provider for the {@link CreativeCentral} instance
*
* @since 1.0.0
*/
public final class CreativeCentralProvider {

// Very based on:
// https://github.com/LuckPerms/LuckPerms/blob/master/api/src/main/java/net/luckperms/api/LuckPermsProvider.java

private static @Nullable CreativeCentral instance;

private CreativeCentralProvider() {
}

public static CreativeCentral get() {
CreativeCentral instance = CreativeCentralProvider.instance;
if (instance == null) {
throw new NotLoadedException();
}
return instance;
}

@ApiStatus.Internal
public static void set(CreativeCentral instance) {
requireNonNull(instance, "instance");
if (CreativeCentralProvider.instance != null) {
throw new IllegalStateException("Service was already set, you cannot set it twice!");
}
CreativeCentralProvider.instance = instance;
}

@ApiStatus.Internal
public static void unset() {
CreativeCentralProvider.instance = null;
}

private static final class NotLoadedException extends IllegalStateException {

private static final String MESSAGE = "Creative Central isn't loaded yet!\n" +
"This could be because:\n" +
" a) The Creative Central plugin is not installed or it failed to enable\n" +
" b) The plugin in the stacktrace does not declare a dependency on Creative Central\n" +
" c) The plugin in the stacktrace is retrieving the API before the plugin 'enable' phase\n" +
" (call the #get method in onEnable, not the constructor!)\n";

NotLoadedException() {
super(MESSAGE);
}

}

}
Loading

0 comments on commit bdb6b6c

Please sign in to comment.