-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
# Conflicts: # gradle.properties
- Loading branch information
Showing
36 changed files
with
522 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Java CI | ||
|
||
on: [ push, pull_request ] | ||
on: [ push, pull_request, workflow_dispatch ] | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/items/ArgParserEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.willfp.eco.internal.items | ||
|
||
import com.willfp.eco.core.items.args.LookupArgParser | ||
import org.bukkit.block.CreatureSpawner | ||
import org.bukkit.entity.EntityType | ||
import org.bukkit.inventory.ItemStack | ||
import org.bukkit.inventory.meta.BlockStateMeta | ||
import org.bukkit.inventory.meta.ItemMeta | ||
import java.util.function.Predicate | ||
|
||
object ArgParserEntity : LookupArgParser { | ||
override fun parseArguments(args: Array<out String>, meta: ItemMeta): Predicate<ItemStack>? { | ||
if (meta !is BlockStateMeta) { | ||
return null | ||
} | ||
|
||
if (meta.hasBlockState() || meta.blockState !is CreatureSpawner) { | ||
return null | ||
} | ||
|
||
val state = meta.blockState as CreatureSpawner | ||
|
||
var type: String? = null | ||
|
||
for (arg in args) { | ||
val argSplit = arg.split(":") | ||
if (!argSplit[0].equals("entity", ignoreCase = true)) { | ||
continue | ||
} | ||
if (argSplit.size < 2) { | ||
continue | ||
} | ||
type = argSplit[1] | ||
} | ||
|
||
type ?: return null | ||
|
||
val entityType = runCatching { EntityType.valueOf(type.uppercase()) }.getOrNull() ?: return null | ||
|
||
state.spawnedType = entityType | ||
|
||
meta.blockState = state | ||
|
||
return Predicate { | ||
val testMeta = ((it.itemMeta as? BlockStateMeta) as? CreatureSpawner) ?: return@Predicate false | ||
|
||
testMeta.spawnedType?.name?.equals(type, true) == true | ||
} | ||
} | ||
|
||
override fun serializeBack(meta: ItemMeta): String? { | ||
if (meta !is BlockStateMeta) { | ||
return null | ||
} | ||
|
||
if (meta.hasBlockState() || meta.blockState !is CreatureSpawner) { | ||
return null | ||
} | ||
|
||
val state = meta.blockState as CreatureSpawner | ||
|
||
return state.spawnedType?.let { "entity:${state.spawnedType!!.name}" } ?: return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/items/ArgParserTrim.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.