Skip to content

Commit

Permalink
Merge pull request #10 from EndlessCodeGroup/version/0.3
Browse files Browse the repository at this point in the history
Version 0.3
  • Loading branch information
osipxd authored Aug 8, 2020
2 parents 953e6f2 + fed50ef commit caaac45
Show file tree
Hide file tree
Showing 57 changed files with 595 additions and 289 deletions.
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# MimicAPI [![Build Status](https://img.shields.io/github/workflow/status/EndlessCodeGroup/MimicAPI/CI?style=flat-square)](https://travis-ci.org/EndlessCodeGroup/MimicAPI) [![Test Coverage](https://img.shields.io/codacy/coverage/cfb98bfdf2b44b9d97f719f051e943a9.svg?style=flat-square)](https://www.codacy.com/app/EndlessCode-Group/MimicAPI?utm_source=github.com&utm_medium=referral&utm_content=EndlessCodeGroup/MimicAPI&utm_campaign=Badge_Coverage) [![Code Quality](https://img.shields.io/codacy/grade/cfb98bfdf2b44b9d97f719f051e943a9.svg?style=flat-square)](https://www.codacy.com/app/EndlessCode-Group/MimicAPI?utm_source%3Dgithub.com%26amp;utm_medium%3Dreferral%26amp;utm_content%3DEndlessCodeGroup/MimicAPI%26amp;utm_campaign%3DBadge_Grade)

# MimicAPI
[![Download](https://img.shields.io/bintray/v/endlesscode/repo/mimic?style=flat-square)](https://bintray.com/endlesscode/repo/mimic/_latestVersion) [![Build Status](https://img.shields.io/github/workflow/status/EndlessCodeGroup/MimicAPI/CI?style=flat-square)](https://travis-ci.org/EndlessCodeGroup/MimicAPI) [![Code Quality](https://img.shields.io/codacy/grade/cfb98bfdf2b44b9d97f719f051e943a9.svg?style=flat-square)](https://www.codacy.com/app/EndlessCode-Group/MimicAPI?utm_source%3Dgithub.com%26amp;utm_medium%3Dreferral%26amp;utm_content%3DEndlessCodeGroup/MimicAPI%26amp;utm_campaign%3DBadge_Grade)
[![license](https://img.shields.io/github/license/EndlessCodeGroup/MimicAPI.svg?style=flat-square)](LICENSE)

[![Logo](images/logo.png)]()
[![Logo](images/logo.png)](#)

Abstraction API for RPG plugins.

Expand All @@ -24,6 +24,38 @@ With Mimic you don't need to download all RPG plugins and write specified code f
It also provides commands to test your API implementation.
Use it as example of Mimic APIs usage and implementation.

## Installation

If you are server owner, just get needed plugin from [Implementations](#implementations) section.
If you are developer you can use [Gradle] or [Maven] to plug MimicAPI to your plugin.

### Gradle

```groovy
repositories {
maven { url "https://dl.bintray.com/endlesscode/repo" }
}
dependencies {
compileOnly("ru.endlesscode.mimic:mimic-bukkit-api:0.3")
}
```

### Maven
```xml
<repository>
<id>bintray-endlesscode-repo</id>
<url>https://dl.bintray.com/endlesscode/repo</url>
</repository>

<dependency>
<groupId>ru.endlesscode.mimic</groupId>
<artifactId>mimic-bukkit-api</artifactId>
<version>0.3</version>
<scope>provided</scope>
</dependency>
```

## Usage

> Look [Implementations](#implementations) pages for API usage examples for your platform.
Expand All @@ -35,7 +67,9 @@ For major changes, please open an issue first to discuss what you would like to
Please make sure to update tests as appropriate.

[Vault]: https://github.com/MilkBowl/Vault
[Gradle]: https://gradle.org/
[Maven]: https://maven.apache.org/

[LevelSystem]: mimic-api/src/main/kotlin/LevelSystem.kt
[ClassSystem]: mimic-api/src/main/kotlin/ClassSystem.kt
[ItemsRegistry]: mimic-api/src/main/kotlin/ItemsRegistry.kt
[LevelSystem]: mimic-api/src/main/kotlin/level/LevelSystem.kt
[ClassSystem]: mimic-api/src/main/kotlin/classes/ClassSystem.kt
[ItemsRegistry]: mimic-api/src/main/kotlin/items/ItemsRegistry.kt
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

// Common configurations for all Mimic projects
subprojects {
version = "0.2"
version = "0.3"
group = "ru.endlesscode.mimic"

configureProject()
Expand Down
5 changes: 3 additions & 2 deletions buildSrc/src/main/kotlin/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

object Dependencies {
// RPG Plugins
const val skillApi = "com.sucy:SkillAPI:3.102"
const val battleLevelsApi = "me.robin.battlelevels:battlelevels-api:6.9.1"
const val skillapi = "com.sucy:SkillAPI:3.102"
const val battlelevels = "me.robin.battlelevels:battlelevels-api:6.9.1"

// Libs
const val acf = "co.aikar:acf-paper:0.5.0-SNAPSHOT"
const val bstats_bukkit = "org.bstats:bstats-bukkit:1.7"

// Testing
private const val jupiter_version = "5.6.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with MimicAPI. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic
package ru.endlesscode.mimic.classes

/**
* System that provides methods to work with player's class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
/*
* This file is part of MimicAPI.
* This file is part of Mimic.
* Copyright (C) 2020 Osip Fatkullin
* Copyright (C) 2020 EndlessCode Group and contributors
*
* MimicAPI is free software: you can redistribute it and/or modify
* Mimic is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MimicAPI is distributed in the hope that it will be useful,
* Mimic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MimicAPI. If not, see <http://www.gnu.org/licenses/>.
* along with Mimic. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic
package ru.endlesscode.mimic.items

/** Service for getting items by theirs ID. Also can be used to match id with item. */
import ru.endlesscode.mimic.MimicService

/** Service for getting items by theirs ID. Also can be used to match ID with item. */
interface ItemsRegistry<ItemStackT : Any> : MimicService {

/** Returns all known item IDs. */
Expand All @@ -32,15 +34,15 @@ interface ItemsRegistry<ItemStackT : Any> : MimicService {
/** Returns `true` if item with given [itemId] exists. */
fun isItemExists(itemId: String): Boolean

/** Returns id that represents given [item], or `null` if the id not found. */
/** Returns ID representing given [item], or `null` if the ID not found in this registry. */
fun getItemId(item: ItemStackT): String?

/** Returns item by given [itemId], or `null` if id not found. */
/** Returns item by given [itemId], or `null` if the ID not found in this registry. */
@JvmDefault
fun getItem(itemId: String): ItemStackT? = getItem(itemId, amount = 1)

/**
* Returns specified item stack with specified [amount] by given [itemId], or `null` if id not found.
* Returns item stack with specified [amount] by given [itemId], or `null` if ID not found in this registry.
*
* If given [amount] is greater than maximum possible, will use maximum possible amount.
* Amount shouldn't be less than `1`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with MimicAPI. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic
package ru.endlesscode.mimic.level

/** Entity that contains all methods needed to convert levels to exp and vice versa. */
interface ExpLevelConverter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/*
* This file is part of MimicAPI.
* This file is part of Mimic.
* Copyright (C) 2020 Osip Fatkullin
* Copyright (C) 2020 EndlessCode Group and contributors
*
* MimicAPI is free software: you can redistribute it and/or modify
* Mimic is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MimicAPI is distributed in the hope that it will be useful,
* Mimic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MimicAPI. If not, see <http://www.gnu.org/licenses/>.
* along with Mimic. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic
package ru.endlesscode.mimic.level

/**
* System that provides methods to work with player's level and experience points.
Expand Down
2 changes: 1 addition & 1 deletion mimic-api/src/main/kotlin/util/Requirements.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package ru.endlesscode.mimic.util

/** Checks that classes are exist. */
fun checkClassesExist(vararg classes: String): Boolean {
fun checkClassesLoaded(vararg classes: String): Boolean {
return try {
classes.forEach { Class.forName(it) }
true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/*
* This file is part of MimicAPI.
* Copyright (C) 2018 Osip Fatkullin
* Copyright (C) 2018 EndlessCode Group and contributors
* This file is part of Mimic.
* Copyright (C) 2020 Osip Fatkullin
* Copyright (C) 2020 EndlessCode Group and contributors
*
* MimicAPI is free software: you can redistribute it and/or modify
* Mimic is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MimicAPI is distributed in the hope that it will be useful,
* Mimic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MimicAPI. If not, see <http://www.gnu.org/licenses/>.
* along with Mimic. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic
package ru.endlesscode.mimic.classes

import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package ru.endlesscode.mimic.exp
/*
* This file is part of Mimic.
* Copyright (C) 2020 Osip Fatkullin
* Copyright (C) 2020 EndlessCode Group and contributors
*
* Mimic is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Mimic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Mimic. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic.level

import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.Arguments.arguments
import org.junit.jupiter.params.provider.MethodSource
import ru.endlesscode.mimic.ExpLevelConverter
import ru.endlesscode.mimic.mockExpLevelConverter
import java.util.stream.Stream
import kotlin.test.BeforeTest
import kotlin.test.assertEquals
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
/*
* This file is part of MimicAPI.
* Copyright (C) 2018 Osip Fatkullin
* Copyright (C) 2018 EndlessCode Group and contributors
* This file is part of Mimic.
* Copyright (C) 2020 Osip Fatkullin
* Copyright (C) 2020 EndlessCode Group and contributors
*
* MimicAPI is free software: you can redistribute it and/or modify
* Mimic is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MimicAPI is distributed in the hope that it will be useful,
* Mimic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MimicAPI. If not, see <http://www.gnu.org/licenses/>.
* along with Mimic. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic.exp
package ru.endlesscode.mimic.level

import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
import ru.endlesscode.mimic.LevelSystem
import ru.endlesscode.mimic.mockExpLevelConverter
import ru.endlesscode.mimic.mockito.MOCKS_ONLY_ABSTRACTS
import ru.endlesscode.mimic.mockito.doubleEq
import kotlin.test.*
Expand Down Expand Up @@ -385,7 +383,7 @@ class LevelSystemTest {
level: Int? = null,
exp: Double? = null
) {
level?.let { whenever(this.level) doReturn it }
exp?.let { whenever(this.exp) doReturn it }
level?.let { whenever(this.level) doReturn it }
exp?.let { whenever(this.exp) doReturn it }
}
}
36 changes: 36 additions & 0 deletions mimic-api/src/test/kotlin/level/mocks.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of Mimic.
* Copyright (C) 2020 Osip Fatkullin
* Copyright (C) 2020 EndlessCode Group and contributors
*
* Mimic is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Mimic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Mimic. If not, see <http://www.gnu.org/licenses/>.
*/

package ru.endlesscode.mimic.level

import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.doAnswer
import com.nhaarman.mockitokotlin2.mock
import ru.endlesscode.mimic.mockito.MOCKS_ONLY_ABSTRACTS

const val EXP_IN_LEVEL = 10.0

fun mockExpLevelConverter(): ExpLevelConverter {
return mock(defaultAnswer = MOCKS_ONLY_ABSTRACTS) {
on { getExpToReachLevel(any()) } doAnswer { invocation ->
val level = invocation.getArgument<Int>(0)
level * EXP_IN_LEVEL
}
}
}
17 changes: 0 additions & 17 deletions mimic-api/src/test/kotlin/mocks.kt

This file was deleted.

1 change: 1 addition & 0 deletions mimic-api/src/test/kotlin/package.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package ru.endlesscode.mimic
Loading

0 comments on commit caaac45

Please sign in to comment.