Skip to content

Commit

Permalink
Merge pull request #86 from gabber235/develop
Browse files Browse the repository at this point in the history
Quality Of Live Update
  • Loading branch information
gabber235 authored Jan 7, 2024
2 parents 7da2bfb + 7741fc3 commit 5568fd8
Show file tree
Hide file tree
Showing 215 changed files with 24,957 additions and 17,267 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: "Builds the plugin and runs tests"
runs:
using: "composite"
steps:
- uses: actions/checkout@v2
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/build-adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ jobs:
with:
distribution: temurin
java-version: 17
- name: Test Adapter
uses: gradle/gradle-build-action@v2
with:
arguments: test --scan
build-root-directory: ./adapters/${{ inputs.adapter }}
- name: Build Adapter
uses: gradle/gradle-build-action@v2
uses: ./.github/actions/build-adapter
with:
arguments: buildRelease --scan
build-root-directory: ./adapters/${{ inputs.adapter }}
adapter: ${{ inputs.adapter }}
- name: Upload Adapter
uses: actions/upload-artifact@v2
with:
Expand Down
41 changes: 40 additions & 1 deletion .github/workflows/build-development-jars-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Development Jars and Publish
on:
pull_request:
branches:
- develop
- main
paths:
- 'plugins/**'
- 'adapters/**'
Expand All @@ -19,6 +19,14 @@ jobs:
with:
distribution: temurin
java-version: 17
- name: Get version
id: vars
run: |
version=$(cat version.txt)
short_sha=$(echo $GITHUB_SHA | cut -c1-7)
full_version="${version}-dev-${short_sha}"
echo $full_version > version.txt
echo "version=$full_version" >> $GITHUB_OUTPUT
- name: Build Plugin
uses: ./.github/actions/build-plugin
- name: Build Basic Adapter
Expand Down Expand Up @@ -53,3 +61,34 @@ jobs:
uses: ./.github/actions/build-adapter
with:
adapter: WorldGuardAdapter
- name: Publish Development Jars
uses: Kir-Antipov/mc-publish@v3.3
id: publish
with:
modrinth-id: "Vm7B3ymm"
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
modrinth-featured: false
files: |
plugin/build/libs/typewriter.jar
adapters/**/build/libs/*.jar
name: "Typewriter v${{ steps.vars.outputs.version }} Development Build"
version: "${{ steps.vars.outputs.version }}"
version-type: "beta"
loaders: |
paper
purpur
game-versions: |
1.19.4
[1.20, 1.20.2]
- name: Notify Discord
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
nodetail: true
title: Published Development Build
description: |
I have published a development build of Typewriter.
Version: ${{ steps.vars.outputs.version }}
[Download](https://modrinth.com/plugin/typewriter/version/${{ steps.publish.outputs.modrinth-version }})
25 changes: 2 additions & 23 deletions .github/workflows/build-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "master"
- name: Get Flutter dependencies
run: flutter pub get
working-directory: ./app
- name: Run tests
run: flutter test
working-directory: ./app
- name: Build web app
run: flutter build web --release --no-tree-shake-icons
working-directory: ./app
- uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Test Plugin
uses: gradle/gradle-build-action@v2
with:
arguments: test --scan
build-root-directory: ./plugin
- name: Build Plugin
uses: gradle/gradle-build-action@v2
with:
arguments: buildRelease --scan
build-root-directory: ./plugin
uses: ./.github/actions/build-plugin
- name: Upload Plugin
uses: actions/upload-artifact@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions adapters/BasicAdapter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ repositories {

dependencies {
compileOnly(kotlin("stdlib"))
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")

compileOnly("me.gabber235:typewriter:$version")
compileOnly("com.github.gabber235:typewriter:$version")

// Already included in the TypeWriter plugin
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0-RC")
Expand Down Expand Up @@ -90,5 +90,6 @@ task<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("buildRelease")
// Rename the jar to remove the version and -all
val jar = file("build/libs/%s-%s-all.jar".format(project.name, project.version))
jar.renameTo(file("build/libs/%s.jar".format(project.name)))
file("build/libs/%s-%s.jar".format(project.name, project.version)).delete()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import lirand.api.extensions.server.commands.dispatchCommand
import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.modifiers.Help
import me.gabber235.typewriter.adapters.modifiers.MultiLine
import me.gabber235.typewriter.adapters.modifiers.Placeholder
import me.gabber235.typewriter.entry.Criteria
import me.gabber235.typewriter.entry.Modifier
Expand All @@ -30,15 +31,19 @@ class ConsoleCommandActionEntry(
override val modifiers: List<Modifier> = emptyList(),
override val triggers: List<String> = emptyList(),
@Placeholder
@Help("The command to run. (Use %player_name% for the player's name)")
// The command that the console will run.
@MultiLine
@Help("The command(s) to run.")
// Every line is a different command. Commands should not be prefixed with <code>/</code>.
private val command: String = "",
) : ActionEntry {
override fun execute(player: Player) {
super.execute(player)
// Run in the main thread
plugin.launch {
Bukkit.getConsoleSender().dispatchCommand(command.parsePlaceholders(player))
val commands = command.parsePlaceholders(player).lines()
for (cmd in commands) {
Bukkit.getConsoleSender().dispatchCommand(cmd)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package me.gabber235.typewriter.entries.action

import com.github.shynixn.mccoroutine.bukkit.launch
import lirand.api.extensions.inventory.meta
import com.google.gson.JsonObject
import lirand.api.extensions.other.set
import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.modifiers.Colored
import me.gabber235.typewriter.adapters.modifiers.Help
import me.gabber235.typewriter.adapters.modifiers.MultiLine
import me.gabber235.typewriter.adapters.modifiers.Placeholder
import me.gabber235.typewriter.entry.Criteria
import me.gabber235.typewriter.entry.Modifier
import me.gabber235.typewriter.entry.*
import me.gabber235.typewriter.entry.entries.ActionEntry
import me.gabber235.typewriter.plugin
import me.gabber235.typewriter.utils.Icons
import me.gabber235.typewriter.utils.asMini
import me.gabber235.typewriter.utils.Item
import me.gabber235.typewriter.utils.optional
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta
import java.util.*

@Entry("drop_item", "Drop an item at location, or on player", Colors.RED, Icons.DROPBOX)
Expand All @@ -39,39 +35,42 @@ class DropItemActionEntry(
override val modifiers: List<Modifier>,
override val triggers: List<String> = emptyList(),
@Help("The item to drop.")
private val material: Material = Material.AIR,
@Help("The amount of items to drop.")
private val amount: Int = 1,
@Colored
@Placeholder
@Help("The display name of the item. (Defaults to the material's display name)")
// The display name of the item to drop. If not specified, the item will have its default display name.
private val displayName: String = "",
@MultiLine
@Colored
@Placeholder
@Help("The lore of the item. (Defaults to the item's lore)")
// The lore of the item to drop. If not specified, the item will have its default lore.
private val lore: String,
val item: Item = Item.Empty,
@Help("The location to drop the item. (Defaults to the player's location)")
// The location to drop the item at. If this field is left blank, the item will be dropped at the location of the player triggering the action.
private val location: Optional<Location> = Optional.empty(),
) : ActionEntry {
override fun execute(player: Player) {
super.execute(player)
val item = ItemStack(material, amount).meta<ItemMeta> {
if (this@DropItemActionEntry.displayName.isNotBlank()) displayName(this@DropItemActionEntry.displayName.asMini())
if (this@DropItemActionEntry.lore.isNotBlank()) {
lore(this@DropItemActionEntry.lore.split("\n").map { "<gray>$it".asMini() })
}
}
// Run on main thread
plugin.launch {
if (location.isPresent) {
location.get().world.dropItem(location.get(), item)
location.get().world.dropItem(location.get(), item.build(player))
} else {
player.location.world.dropItem(player.location, item)
player.location.world.dropItem(player.location, item.build(player))
}
}
}
}
}

@EntryMigration(DropItemActionEntry::class, "0.4.0")
@NeedsMigrationIfContainsAny(["material", "amount", "displayName", "lore"])
fun migrate040DropItemAction(json: JsonObject, context: EntryMigratorContext): JsonObject {
val data = JsonObject()
data.copyAllBut(json, "material", "amount", "displayName", "lore")

val material = json.getAndParse<Material>("material", context.gson).optional
val amount = json.getAndParse<Int>("amount", context.gson).optional
val displayName = json.getAndParse<String>("displayName", context.gson).optional
val lore = json.getAndParse<String>("lore", context.gson).optional

val item = Item(
material = material,
amount = amount,
name = displayName,
lore = lore,
)
data["item"] = context.gson.toJsonTree(item)

return data
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package me.gabber235.typewriter.entries.action

import lirand.api.extensions.inventory.meta
import com.google.gson.JsonObject
import lirand.api.extensions.other.set
import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.modifiers.Colored
import me.gabber235.typewriter.adapters.modifiers.Help
import me.gabber235.typewriter.adapters.modifiers.MultiLine
import me.gabber235.typewriter.adapters.modifiers.Placeholder
import me.gabber235.typewriter.entry.Criteria
import me.gabber235.typewriter.entry.Modifier
import me.gabber235.typewriter.entry.*
import me.gabber235.typewriter.entry.entries.ActionEntry
import me.gabber235.typewriter.utils.Icons
import me.gabber235.typewriter.utils.asMini
import me.gabber235.typewriter.utils.Item
import me.gabber235.typewriter.utils.optional
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.ItemMeta

@Entry("give_item", "Give an item to the player", Colors.RED, Icons.WAND_SPARKLES)
/**
Expand All @@ -32,34 +28,33 @@ class GiveItemActionEntry(
override val modifiers: List<Modifier>,
override val triggers: List<String> = emptyList(),
@Help("The item to give.")
// The Minecraft material of the item to give.
private val material: Material = Material.AIR,
@Help("The amount of items to give.")
private val amount: Int = 1,
@Colored
@Placeholder
@Help("The display name of the item. (Defaults to the item's display name)")
// The display name of the item to give. If not specified, the item will have it's default display name.
private val displayName: String = "",
@MultiLine
@Colored
@Placeholder
@Help("The lore of the item. (Defaults to the item's lore)")
// The lore of the item to give. If not specified, the item will have it's default lore.
private val lore: String,
val item: Item = Item.Empty,
) : ActionEntry {
override fun execute(player: Player) {
super.execute(player)

val item = ItemStack(material, amount).meta<ItemMeta> {
if (this@GiveItemActionEntry.displayName.isNotBlank()) displayName(this@GiveItemActionEntry.displayName.asMini())
if (this@GiveItemActionEntry.lore.isNotBlank()) {
lore(
this@GiveItemActionEntry.lore.split("\n").map { "<gray>$it".asMini() })
player.inventory.addItem(item.build(player))
}
}

}
}
@EntryMigration(GiveItemActionEntry::class, "0.4.0")
@NeedsMigrationIfContainsAny(["material", "amount", "displayName", "lore"])
fun migrate040GiveItemAction(json: JsonObject, context: EntryMigratorContext): JsonObject {
val data = JsonObject()
data.copyAllBut(json, "material", "amount", "displayName", "lore")

player.inventory.addItem(item)
}
val material = json.getAndParse<Material>("material", context.gson).optional
val amount = json.getAndParse<Int>("amount", context.gson).optional
val displayName = json.getAndParse<String>("displayName", context.gson).optional
val lore = json.getAndParse<String>("lore", context.gson).optional

val item = Item(
material = material,
amount = amount,
name = displayName,
lore = lore,
)
data["item"] = context.gson.toJsonTree(item)

return data
}
Loading

0 comments on commit 5568fd8

Please sign in to comment.