Skip to content

Commit 5568fd8

Browse files
authored
Merge pull request #86 from gabber235/develop
Quality Of Live Update
2 parents 7da2bfb + 7741fc3 commit 5568fd8

File tree

215 files changed

+24957
-17267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+24957
-17267
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ description: "Builds the plugin and runs tests"
44
runs:
55
using: "composite"
66
steps:
7-
- uses: actions/checkout@v2
87
- name: Setup Flutter
98
uses: subosito/flutter-action@v2
109
with:

.github/workflows/build-adapter.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@ jobs:
1919
with:
2020
distribution: temurin
2121
java-version: 17
22-
- name: Test Adapter
23-
uses: gradle/gradle-build-action@v2
24-
with:
25-
arguments: test --scan
26-
build-root-directory: ./adapters/${{ inputs.adapter }}
2722
- name: Build Adapter
28-
uses: gradle/gradle-build-action@v2
23+
uses: ./.github/actions/build-adapter
2924
with:
30-
arguments: buildRelease --scan
31-
build-root-directory: ./adapters/${{ inputs.adapter }}
25+
adapter: ${{ inputs.adapter }}
3226
- name: Upload Adapter
3327
uses: actions/upload-artifact@v2
3428
with:

.github/workflows/build-development-jars-and-publish.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build Development Jars and Publish
33
on:
44
pull_request:
55
branches:
6-
- develop
6+
- main
77
paths:
88
- 'plugins/**'
99
- 'adapters/**'
@@ -19,6 +19,14 @@ jobs:
1919
with:
2020
distribution: temurin
2121
java-version: 17
22+
- name: Get version
23+
id: vars
24+
run: |
25+
version=$(cat version.txt)
26+
short_sha=$(echo $GITHUB_SHA | cut -c1-7)
27+
full_version="${version}-dev-${short_sha}"
28+
echo $full_version > version.txt
29+
echo "version=$full_version" >> $GITHUB_OUTPUT
2230
- name: Build Plugin
2331
uses: ./.github/actions/build-plugin
2432
- name: Build Basic Adapter
@@ -53,3 +61,34 @@ jobs:
5361
uses: ./.github/actions/build-adapter
5462
with:
5563
adapter: WorldGuardAdapter
64+
- name: Publish Development Jars
65+
uses: Kir-Antipov/mc-publish@v3.3
66+
id: publish
67+
with:
68+
modrinth-id: "Vm7B3ymm"
69+
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
70+
modrinth-featured: false
71+
files: |
72+
plugin/build/libs/typewriter.jar
73+
adapters/**/build/libs/*.jar
74+
name: "Typewriter v${{ steps.vars.outputs.version }} Development Build"
75+
version: "${{ steps.vars.outputs.version }}"
76+
version-type: "beta"
77+
loaders: |
78+
paper
79+
purpur
80+
game-versions: |
81+
1.19.4
82+
[1.20, 1.20.2]
83+
- name: Notify Discord
84+
uses: sarisia/actions-status-discord@v1
85+
with:
86+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
87+
nodetail: true
88+
title: Published Development Build
89+
description: |
90+
I have published a development build of Typewriter.
91+
Version: ${{ steps.vars.outputs.version }}
92+
[Download](https://modrinth.com/plugin/typewriter/version/${{ steps.publish.outputs.modrinth-version }})
93+
94+

.github/workflows/build-plugin.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,14 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- name: Setup Flutter
11-
uses: subosito/flutter-action@v2
12-
with:
13-
channel: "master"
14-
- name: Get Flutter dependencies
15-
run: flutter pub get
16-
working-directory: ./app
17-
- name: Run tests
18-
run: flutter test
19-
working-directory: ./app
20-
- name: Build web app
21-
run: flutter build web --release --no-tree-shake-icons
22-
working-directory: ./app
9+
- uses: actions/checkout@v3
2310
- name: Setup Java
2411
uses: actions/setup-java@v3
2512
with:
2613
distribution: temurin
2714
java-version: 17
28-
- name: Test Plugin
29-
uses: gradle/gradle-build-action@v2
30-
with:
31-
arguments: test --scan
32-
build-root-directory: ./plugin
3315
- name: Build Plugin
34-
uses: gradle/gradle-build-action@v2
35-
with:
36-
arguments: buildRelease --scan
37-
build-root-directory: ./plugin
16+
uses: ./.github/actions/build-plugin
3817
- name: Upload Plugin
3918
uses: actions/upload-artifact@v2
4019
with:

adapters/BasicAdapter/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ repositories {
2222

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

27-
compileOnly("me.gabber235:typewriter:$version")
27+
compileOnly("com.github.gabber235:typewriter:$version")
2828

2929
// Already included in the TypeWriter plugin
3030
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0-RC")
@@ -90,5 +90,6 @@ task<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("buildRelease")
9090
// Rename the jar to remove the version and -all
9191
val jar = file("build/libs/%s-%s-all.jar".format(project.name, project.version))
9292
jar.renameTo(file("build/libs/%s.jar".format(project.name)))
93+
file("build/libs/%s-%s.jar".format(project.name, project.version)).delete()
9394
}
9495
}

adapters/BasicAdapter/src/main/kotlin/me/gabber235/typewriter/entries/action/ConsoleCommandActionEntry.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import lirand.api.extensions.server.commands.dispatchCommand
55
import me.gabber235.typewriter.adapters.Colors
66
import me.gabber235.typewriter.adapters.Entry
77
import me.gabber235.typewriter.adapters.modifiers.Help
8+
import me.gabber235.typewriter.adapters.modifiers.MultiLine
89
import me.gabber235.typewriter.adapters.modifiers.Placeholder
910
import me.gabber235.typewriter.entry.Criteria
1011
import me.gabber235.typewriter.entry.Modifier
@@ -30,15 +31,19 @@ class ConsoleCommandActionEntry(
3031
override val modifiers: List<Modifier> = emptyList(),
3132
override val triggers: List<String> = emptyList(),
3233
@Placeholder
33-
@Help("The command to run. (Use %player_name% for the player's name)")
34-
// The command that the console will run.
34+
@MultiLine
35+
@Help("The command(s) to run.")
36+
// Every line is a different command. Commands should not be prefixed with <code>/</code>.
3537
private val command: String = "",
3638
) : ActionEntry {
3739
override fun execute(player: Player) {
3840
super.execute(player)
3941
// Run in the main thread
4042
plugin.launch {
41-
Bukkit.getConsoleSender().dispatchCommand(command.parsePlaceholders(player))
43+
val commands = command.parsePlaceholders(player).lines()
44+
for (cmd in commands) {
45+
Bukkit.getConsoleSender().dispatchCommand(cmd)
46+
}
4247
}
4348
}
4449
}
Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
package me.gabber235.typewriter.entries.action
22

33
import com.github.shynixn.mccoroutine.bukkit.launch
4-
import lirand.api.extensions.inventory.meta
4+
import com.google.gson.JsonObject
5+
import lirand.api.extensions.other.set
56
import me.gabber235.typewriter.adapters.Colors
67
import me.gabber235.typewriter.adapters.Entry
7-
import me.gabber235.typewriter.adapters.modifiers.Colored
88
import me.gabber235.typewriter.adapters.modifiers.Help
9-
import me.gabber235.typewriter.adapters.modifiers.MultiLine
10-
import me.gabber235.typewriter.adapters.modifiers.Placeholder
11-
import me.gabber235.typewriter.entry.Criteria
12-
import me.gabber235.typewriter.entry.Modifier
9+
import me.gabber235.typewriter.entry.*
1310
import me.gabber235.typewriter.entry.entries.ActionEntry
1411
import me.gabber235.typewriter.plugin
1512
import me.gabber235.typewriter.utils.Icons
16-
import me.gabber235.typewriter.utils.asMini
13+
import me.gabber235.typewriter.utils.Item
14+
import me.gabber235.typewriter.utils.optional
1715
import org.bukkit.Location
1816
import org.bukkit.Material
1917
import org.bukkit.entity.Player
20-
import org.bukkit.inventory.ItemStack
21-
import org.bukkit.inventory.meta.ItemMeta
2218
import java.util.*
2319

2420
@Entry("drop_item", "Drop an item at location, or on player", Colors.RED, Icons.DROPBOX)
@@ -39,39 +35,42 @@ class DropItemActionEntry(
3935
override val modifiers: List<Modifier>,
4036
override val triggers: List<String> = emptyList(),
4137
@Help("The item to drop.")
42-
private val material: Material = Material.AIR,
43-
@Help("The amount of items to drop.")
44-
private val amount: Int = 1,
45-
@Colored
46-
@Placeholder
47-
@Help("The display name of the item. (Defaults to the material's display name)")
48-
// The display name of the item to drop. If not specified, the item will have its default display name.
49-
private val displayName: String = "",
50-
@MultiLine
51-
@Colored
52-
@Placeholder
53-
@Help("The lore of the item. (Defaults to the item's lore)")
54-
// The lore of the item to drop. If not specified, the item will have its default lore.
55-
private val lore: String,
38+
val item: Item = Item.Empty,
5639
@Help("The location to drop the item. (Defaults to the player's location)")
5740
// 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.
5841
private val location: Optional<Location> = Optional.empty(),
5942
) : ActionEntry {
6043
override fun execute(player: Player) {
6144
super.execute(player)
62-
val item = ItemStack(material, amount).meta<ItemMeta> {
63-
if (this@DropItemActionEntry.displayName.isNotBlank()) displayName(this@DropItemActionEntry.displayName.asMini())
64-
if (this@DropItemActionEntry.lore.isNotBlank()) {
65-
lore(this@DropItemActionEntry.lore.split("\n").map { "<gray>$it".asMini() })
66-
}
67-
}
6845
// Run on main thread
6946
plugin.launch {
7047
if (location.isPresent) {
71-
location.get().world.dropItem(location.get(), item)
48+
location.get().world.dropItem(location.get(), item.build(player))
7249
} else {
73-
player.location.world.dropItem(player.location, item)
50+
player.location.world.dropItem(player.location, item.build(player))
7451
}
7552
}
7653
}
77-
}
54+
}
55+
56+
@EntryMigration(DropItemActionEntry::class, "0.4.0")
57+
@NeedsMigrationIfContainsAny(["material", "amount", "displayName", "lore"])
58+
fun migrate040DropItemAction(json: JsonObject, context: EntryMigratorContext): JsonObject {
59+
val data = JsonObject()
60+
data.copyAllBut(json, "material", "amount", "displayName", "lore")
61+
62+
val material = json.getAndParse<Material>("material", context.gson).optional
63+
val amount = json.getAndParse<Int>("amount", context.gson).optional
64+
val displayName = json.getAndParse<String>("displayName", context.gson).optional
65+
val lore = json.getAndParse<String>("lore", context.gson).optional
66+
67+
val item = Item(
68+
material = material,
69+
amount = amount,
70+
name = displayName,
71+
lore = lore,
72+
)
73+
data["item"] = context.gson.toJsonTree(item)
74+
75+
return data
76+
}
Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
package me.gabber235.typewriter.entries.action
22

3-
import lirand.api.extensions.inventory.meta
3+
import com.google.gson.JsonObject
4+
import lirand.api.extensions.other.set
45
import me.gabber235.typewriter.adapters.Colors
56
import me.gabber235.typewriter.adapters.Entry
6-
import me.gabber235.typewriter.adapters.modifiers.Colored
77
import me.gabber235.typewriter.adapters.modifiers.Help
8-
import me.gabber235.typewriter.adapters.modifiers.MultiLine
9-
import me.gabber235.typewriter.adapters.modifiers.Placeholder
10-
import me.gabber235.typewriter.entry.Criteria
11-
import me.gabber235.typewriter.entry.Modifier
8+
import me.gabber235.typewriter.entry.*
129
import me.gabber235.typewriter.entry.entries.ActionEntry
1310
import me.gabber235.typewriter.utils.Icons
14-
import me.gabber235.typewriter.utils.asMini
11+
import me.gabber235.typewriter.utils.Item
12+
import me.gabber235.typewriter.utils.optional
1513
import org.bukkit.Material
1614
import org.bukkit.entity.Player
17-
import org.bukkit.inventory.ItemStack
18-
import org.bukkit.inventory.meta.ItemMeta
1915

2016
@Entry("give_item", "Give an item to the player", Colors.RED, Icons.WAND_SPARKLES)
2117
/**
@@ -32,34 +28,33 @@ class GiveItemActionEntry(
3228
override val modifiers: List<Modifier>,
3329
override val triggers: List<String> = emptyList(),
3430
@Help("The item to give.")
35-
// The Minecraft material of the item to give.
36-
private val material: Material = Material.AIR,
37-
@Help("The amount of items to give.")
38-
private val amount: Int = 1,
39-
@Colored
40-
@Placeholder
41-
@Help("The display name of the item. (Defaults to the item's display name)")
42-
// The display name of the item to give. If not specified, the item will have it's default display name.
43-
private val displayName: String = "",
44-
@MultiLine
45-
@Colored
46-
@Placeholder
47-
@Help("The lore of the item. (Defaults to the item's lore)")
48-
// The lore of the item to give. If not specified, the item will have it's default lore.
49-
private val lore: String,
31+
val item: Item = Item.Empty,
5032
) : ActionEntry {
5133
override fun execute(player: Player) {
5234
super.execute(player)
5335

54-
val item = ItemStack(material, amount).meta<ItemMeta> {
55-
if (this@GiveItemActionEntry.displayName.isNotBlank()) displayName(this@GiveItemActionEntry.displayName.asMini())
56-
if (this@GiveItemActionEntry.lore.isNotBlank()) {
57-
lore(
58-
this@GiveItemActionEntry.lore.split("\n").map { "<gray>$it".asMini() })
36+
player.inventory.addItem(item.build(player))
37+
}
38+
}
5939

60-
}
61-
}
40+
@EntryMigration(GiveItemActionEntry::class, "0.4.0")
41+
@NeedsMigrationIfContainsAny(["material", "amount", "displayName", "lore"])
42+
fun migrate040GiveItemAction(json: JsonObject, context: EntryMigratorContext): JsonObject {
43+
val data = JsonObject()
44+
data.copyAllBut(json, "material", "amount", "displayName", "lore")
6245

63-
player.inventory.addItem(item)
64-
}
46+
val material = json.getAndParse<Material>("material", context.gson).optional
47+
val amount = json.getAndParse<Int>("amount", context.gson).optional
48+
val displayName = json.getAndParse<String>("displayName", context.gson).optional
49+
val lore = json.getAndParse<String>("lore", context.gson).optional
50+
51+
val item = Item(
52+
material = material,
53+
amount = amount,
54+
name = displayName,
55+
lore = lore,
56+
)
57+
data["item"] = context.gson.toJsonTree(item)
58+
59+
return data
6560
}

0 commit comments

Comments
 (0)