Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
add some stuff in #23 and fix some other stuff idk
Browse files Browse the repository at this point in the history
  • Loading branch information
dkim19375 committed Sep 19, 2021
1 parent 150864e commit 2610ff7
Show file tree
Hide file tree
Showing 32 changed files with 714 additions and 320 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/gradle_11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,4 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew shadowJar
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: Bedwars Plugin JAR
path: build/libs/*.jar
if-no-files-found: error
run: ./gradlew shadowJar
8 changes: 1 addition & 7 deletions .github/workflows/gradle_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,4 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew shadowJar
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: Bedwars Plugin JAR
path: build/libs/*.jar
if-no-files-found: error
run: ./gradlew shadowJar
20 changes: 3 additions & 17 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//file:noinspection GroovyAssignabilityCheck
/*plugins {
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
plugins {
id 'maven-publish'
id 'signing'
}*/
}

archivesBaseName = "Bedwars-API"

Expand All @@ -16,7 +15,6 @@ java {
withJavadocJar()
}

/*
publishing {
def project = project
publications {
Expand Down Expand Up @@ -57,18 +55,6 @@ publishing {
}
}

nexusPublishing {
packageGroup.set("io.github.dkim19375")
repositories {
sonatype {
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
username = project.findProperty("mavenUsername")
password = project.findProperty("mavenPassword")
}
}
}
signing {
sign publishing.publications.mavenJava
}*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package me.dkim19375.bedwars.api.enumclass;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;

public enum SpecialItemType {
BED_BUGS,
DREAM_DEFENDER,
MAGIC_MILK,
BRIDGE_EGGS;

@Nullable
@Contract(value = "null -> null", pure = true)
public static SpecialItemType fromString(@Nullable String str) {
if (str == null) {
return null;
}
try {
return valueOf(str.toUpperCase());
} catch (IllegalArgumentException ignored) {
return null;
}
}
}
23 changes: 18 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
//file:noinspection SpellCheckingInspection
//file:noinspection GroovyAssignabilityCheck
plugins {
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'org.jetbrains.kotlin.jvm' version '1.5.30'
id 'org.cadixdev.licenser' version '0.6.1'
id 'org.jetbrains.dokka' version '1.4.32'
id 'io.github.slimjar' version '1.3.0'
id 'maven-publish'
id 'signing'
}

final def basePackage = 'me.dkim19375.bedwars.libs'
Expand Down Expand Up @@ -120,19 +124,16 @@ subprojects {

repositories {
addRepositories(project)
maven {
url 'https://repo.maven.apache.org/maven2'
name 'Maven Central'
}
}

dependencies {
dependencyStrings.forEach { compileOnly it }
//noinspection GrUnresolvedAccess
implementation slimjar('1.2.6')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30'


implementation('io.github.dkim19375:dkim-bukkit-core:3.3.7') {
implementation('io.github.dkim19375:dkim-bukkit-core:3.3.11') {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.jetbrains.kotlinx'
}
Expand All @@ -157,6 +158,18 @@ subprojects {
}
}

nexusPublishing {
packageGroup = 'io.github.dkim19375'
repositories {
sonatype {
nexusUrl = uri 'https://s01.oss.sonatype.org/service/local/'
snapshotRepositoryUrl = uri 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
username = project.findProperty 'mavenUsername'
password = project.findProperty 'mavenPassword'
}
}
}

task removeBuildJars() {
new File('build/libs').deleteDir()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package me.dkim19375.bedwars.compat.abstract

import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Entity
import org.bukkit.entity.Item
import org.bukkit.entity.LivingEntity
import org.bukkit.inventory.ItemStack
Expand All @@ -29,21 +30,23 @@ import org.bukkit.plugin.java.JavaPlugin
abstract class NBTUtilitiesAbstract {

companion object {
fun getInstance(plugin: JavaPlugin): NBTUtilitiesAbstract = if (MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_16_R1)) {
Class.forName("me.dkim19375.bedwars.v1_16.NBTUtilities")
.getConstructor(JavaPlugin::class.java)
.newInstance(plugin) as NBTUtilitiesAbstract
} else {
Class.forName("me.dkim19375.bedwars.v1_8.NBTUtilities")
.getConstructor()
.newInstance() as NBTUtilitiesAbstract
}
fun getInstance(plugin: JavaPlugin): NBTUtilitiesAbstract =
if (MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_16_R1)) {
Class.forName("me.dkim19375.bedwars.v1_16.NBTUtilities")
.getConstructor(JavaPlugin::class.java)
.newInstance(plugin) as NBTUtilitiesAbstract
} else {
Class.forName("me.dkim19375.bedwars.v1_8.NBTUtilities")
.getConstructor()
.newInstance() as NBTUtilitiesAbstract
}
}

protected val CONFIG_ITEM_KEY = "BedwarsConfigItem"
protected val HOLOGRAM_KEY = "BedwarsArmorStand"
protected val MOB_DROP_KEY = "BedwarsMobDrop"
protected val GEN_DROP_KEY = "BedwarsGenDrop"
protected val TRACKER_KEY = "BedwarsPlayerTracker"
protected val DROP_KEY = "BedwarsGenDrop"

abstract fun <T : LivingEntity> addAI(entity: T)

Expand All @@ -64,4 +67,8 @@ abstract class NBTUtilitiesAbstract {
abstract fun setDrop(item: Item, drop: Boolean): Item

abstract fun isDrop(item: Item): Pair<Boolean, Item>

abstract fun <T : Entity> disableDrops(entity: T): T

abstract fun <T : Entity> isDropsDisabled(entity: T): Pair<Boolean, T>
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ val NEW_SOUND: Boolean = MinecraftVersion.isAtLeastVersion(MinecraftVersion.MC1_
class BedwarsPlugin : CoreJavaPlugin() {
val mainConfigManager: MainConfigManager by lazy { MainConfigManager(this) }
val shopConfigManager = ShopConfigManager(this)
val shopFile = ConfigFile(this, "shop.yml")
val shopFile by lazy { ConfigFile(this, "shop.yml") }
val gameDataFiles = mutableMapOf<String, JsonFile<GameData>>()
val userCache: MutableMap<String, UUID> = Collections.synchronizedMap(mutableMapOf<String, UUID>())
val mainDataFile: JsonFile<MainDataFile> by lazy {
JsonFile(
type = MainDataFile::class,
fileName = File(dataFolder, "data/data.json").path,
file = File(dataFolder, "data/data.json"),
prettyPrinting = true,
typeAdapters = jsonSerializers,
default = { MainDataFile() }
Expand Down Expand Up @@ -109,9 +108,9 @@ class BedwarsPlugin : CoreJavaPlugin() {

val jsonSerializers by lazy {
mapOf<Class<*>, Any>(
Location::class.java to LocationSerializer(),
MainShopConfigItem::class.java to ShopConfigItemSerializer(this),
World::class.java to WorldSerializer()
Location::class.java to LocationSerializer().nullSafe(),
MainShopConfigItem::class.java to ShopConfigItemSerializer(this).nullSafe(),
World::class.java to WorldSerializer().nullSafe()
)
}

Expand Down Expand Up @@ -166,7 +165,7 @@ class BedwarsPlugin : CoreJavaPlugin() {
val data = GameBuilder(world).build(true) ?: continue
val newData = JsonFile(
type = GameData::class,
fileName = file.path,
file = file,
prettyPrinting = true,
typeAdapters = jsonSerializers,
default = { data }
Expand Down Expand Up @@ -221,7 +220,7 @@ class BedwarsPlugin : CoreJavaPlugin() {
PotionConsumeListener(this), InventoryClickListener(this), PlayerPickupItemListener(this),
WorldInitListener(this), CommandListeners(this), AsyncPlayerChatListener(this),
PlayerCoordsChangeListener(this), EntityDamageByEntityListener(this), CraftItemListener(this),
PlayerInteractListener(this), ProjectileLaunchListener(this),
PlayerInteractListener(this), ProjectileLaunchListener(this), EntityDeathListener(),
partiesListeners, scoreboardManager
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import me.dkim19375.dkimcore.file.YamlFile
import java.io.File

class MainConfigManager(plugin: BedwarsPlugin) :
YamlFile(MainConfigSettings, File(plugin.dataFolder, "config.yml").path)
YamlFile(MainConfigSettings, File(plugin.dataFolder, "config.yml"))
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ object MainConfigSettings : SettingsHolder {
@Path("map.protection")
val MAP_PROTECTION: Property<Boolean> = Property.create(true)

// mobs
@Path("mobs.time.dream-defender")
val TIME_DREAM_DEFENDER: Property<Int> = Property.create(4800)
@Path("mobs.time.bed-bugs")
val TIME_BED_BUG: Property<Int> = Property.create(300)

override fun registerComments(conf: CommentsConfiguration) {
conf.setComment(
"tab.hide-players",
"Players in-game won't see players not in the game and players not in the game won't see players in-game",
"unless in the same world (and same-world is true)"
)
conf.setComment("mobs.time", "The time that these mobs will stay in TICKS (20 ticks = 1 second)")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ShopConfigManager(private val plugin: BedwarsPlugin) {
fun update() {
mainItems = shopConfig.getKeys(false)
.mapNotNull(shopConfig::getConfigurationSection)
.mapNotNull(MainShopConfigItem::deserialize)
.mapNotNull { MainShopConfigItem.deserialize(it, plugin) }
.toSet()
}

Expand Down
Loading

0 comments on commit 2610ff7

Please sign in to comment.