That's my project on writing the Minecraft plugin using Scala as the main language, supported by Java. I'm using Gradle and some settings to combine Scala and Java.
I've had a working prototype of one of the modules and then added some refactoring, that somehow called the exception. As far as I've researched, there are only 3 to 8 results on the search, related to the "NoDenotation.owner" exception. Now I have no idea how to resolve it and there are no comments on it on the StackOverflow as well.
Here is my build.gradle file (I'll fix shadowing part later):
plugins {
id 'java'
id 'scala'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
group = 'com.danikvitek'
version = '1.0'
sourceSets {
main {
scala.srcDirs = ["$projectDir/src/main/mixed"]
resources.srcDirs = ["$projectDir/src/main/resources"]
}
test {
scala.srcDirs = ["$projectDir/src/test/mixed"]
resources.srcDirs = ["$projectDir/src/test/resources"]
}
}
repositories {
mavenCentral()
maven {
name = 'papermc-repo'
url = 'https://papermc.io/repo/repository/maven-public/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
maven {
name = 'codemc-snapshots'
url = 'https://repo.codemc.io/repository/maven-snapshots/'
}
maven { url "https://repo.dmulloy2.net/repository/public/" }
}
dependencies {
implementation 'org.hibernate:hibernate-core:5.6.3.Final'
implementation 'org.hibernate:hibernate-entitymanager:5.6.3.Final'
implementation 'mysql:mysql-connector-java:8.0.25'
implementation 'net.wesjd:anvilgui:1.5.3-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
// compileOnly group: "com.comphenix.protocol", name: "ProtocolLib", version: "4.7.0";
compileOnly group: 'org.scala-lang', name: 'scala3-library_3', version: '3.1.0'
testImplementation group: 'org.scala-lang', name: 'scala3-library_3', version: '3.1.0'
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
def targetJavaVersion = 16
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
And here is the exception stacktrace:
## Exception when compiling 84 sources to D:\Desktop\Minecraft plugins\PoliticsCountryS\build\classes\scala\main
java.lang.AssertionError: NoDenotation.owner
dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2503)
dotty.tools.dotc.typer.Typer.canAssign$1(Typer.scala:959)
dotty.tools.dotc.typer.Typer.typedAssign(Typer.scala:996)
dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2762)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2818)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2883)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2887)
dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2936)
dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2959)
dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1027)
dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1031)
dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2763)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2818)
dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$5(ProtoTypes.scala:431)
dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:359)
dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:432)
dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:853)
dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:853)
dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:544)
dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:609)
dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:609)
dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:609)
dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:447)
dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:735)
dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:852)
dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1060)
dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:317)
dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:107)
dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:907)
dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:986)
dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3011)
dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:997)
dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1035)
dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:317)
dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:107)
dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2755)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2818)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2883)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2887)
dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3003)
dotty.tools.dotc.typer.Typer.typedParent$2(Typer.scala:2321)
dotty.tools.dotc.typer.Typer.$anonfun$40(Typer.scala:2396)
dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:92)
dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:108)
dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2396)
dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2743)
dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2747)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2817)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2883)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2887)
dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2909)
dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2959)
dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2532)
dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2788)
dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2818)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2883)
dotty.tools.dotc.typer.Typer.typed(Typer.scala:2887)
dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3003)
dotty.tools.dotc.typer.TyperPhase.liftedTree1$1(TyperPhase.scala:56)
dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:62)
dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:411)
dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:63)
dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$1(TyperPhase.scala:105)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
scala.collection.immutable.List.foreach(List.scala:333)
dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:105)
dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:261)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
dotty.tools.dotc.Run.runPhases$5(Run.scala:272)
dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:280)
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
dotty.tools.dotc.Run.compileUnits(Run.scala:289)
dotty.tools.dotc.Run.compileSources(Run.scala:222)
dotty.tools.dotc.Run.compile(Run.scala:206)
dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
dotty.tools.dotc.Driver.process(Driver.scala:199)
dotty.tools.dotc.Main.process(Main.scala)
xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:67)
xsbt.CompilerInterface.run(CompilerInterface.java:59)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:568)
sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
org.gradle.api.internal.tasks.scala.ZincScalaCompiler.execute(ZincScalaCompiler.java:157)
org.gradle.api.internal.tasks.scala.ZincScalaCompilerFacade.execute(ZincScalaCompilerFacade.java:47)
org.gradle.api.internal.tasks.scala.ZincScalaCompilerFacade.execute(ZincScalaCompilerFacade.java:32)
org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:85)
org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:55)
org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:568)
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
java.base/java.lang.Thread.run(Thread.java:833)
Here are the places, where the new code was added:
PMenuCommand.scala:
package com.danikvitek.politicscountry.ui.command
import com.danikvitek.politicscountry.ui.gui.prefab.PMenu
import com.danikvitek.politicscountry.ui.gui.{Menu, MenuHandler}
import com.danikvitek.politicscountry.utils.Translation
import org.bukkit.{Bukkit, ChatColor}
import org.bukkit.command.{Command, CommandSender, TabExecutor}
import org.bukkit.entity.Player
import org.bukkit.inventory.Inventory
import java.util
class PMenuCommand extends TabExecutor {
override def onCommand(sender: CommandSender, command: Command,
alias: String, args: Array[String]): Boolean = {
sender match {
case player: Player =>
if player hasPermission "politicscountry.command.pmenu" then {
val menu: Menu = new PMenu(player)
MenuHandler.openMenu(player, menu)
}
else
player sendMessage Translation.`you have no permission to use this command`
case _ => sender sendMessage (ChatColor.RED.toString + "You need to be a player to use this command")
}
true
}
override def onTabComplete(sender: CommandSender, command: Command,
alias: String, args: Array[String]): util.List[String] = {
new util.ArrayList[String]
}
}
PMenu.scala:
package com.danikvitek.politicscountry.ui.gui.prefab
import com.danikvitek.politicscountry.ui.gui.{Button, Menu, MenuHandler}
import com.danikvitek.politicscountry.utils.{ItemBuilder, Translation}
import org.bukkit.{Bukkit, ChatColor, Material}
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.inventory.{Inventory, ItemStack}
import com.danikvitek.politicscountry.api.controller.{FormationManager, ResidentManager}
import com.danikvitek.politicscountry.RichPlayer
import com.danikvitek.politicscountry.gameplay.residency.Resident
import net.kyori.adventure.text.Component
import net.wesjd.anvilgui.AnvilGUI
import org.bukkit.entity.Player
import scala.collection.mutable
class PMenu(player: Player)
extends DoubleChestMenu(Component.text(Translation.`pmenu inventory title`)) {
private lazy val resident = player.toResident
private lazy val statusButton = new Button(Material.RED_STAINED_GLASS_PANE, Translation.`status`) {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = {
event setCancelled true
val statusMenu: Menu = new Status(resident)
MenuHandler.closeMenu(player)
MenuHandler.openMenu(player, statusMenu)
}
}
private lazy val createFormationButton = new Button(Material.RED_STAINED_GLASS_PANE, Translation.`create formation`) {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = {
event setCancelled true
var title: String = null
new AnvilGUI.Builder()
.title(Translation.`create formation`)
.itemLeft(new ItemStack(Material.PAPER))
.text(Translation.`input formation title`)
.onClose { p =>
MenuHandler.closeMenu(p)
p.performCommand("pmenu")
}
.onComplete { (p, t) =>
title = t
AnvilGUI.Response.close()
}
.open(player)
val chunk = player.getLocation.getChunk()
FormationManager.create(title, chunk, resident)
}
}
setButton(24, statusButton)
if resident.feud.isEmpty then
setButton(13, createFormationButton)
}
SingleChestMenu.scala:
package com.danikvitek.politicscountry.ui.gui.prefab
import com.danikvitek.politicscountry.ui.gui.{Button, Menu}
import com.danikvitek.politicscountry.utils.Translation
import net.kyori.adventure.text.Component
import org.bukkit.{Bukkit, Material}
import org.bukkit.event.inventory.InventoryClickEvent
abstract class SingleChestMenu(title: Component)
extends Menu(Bukkit.createInventory(null, 27, title)) {
def this(title: String) = this(Component.text(title))
for {
slot <- Seq(0, 1, 7, 8, 18, 19, 25, 26)
} setButton(slot, new Button(Material.BLUE_STAINED_GLASS_PANE, " ") {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = event setCancelled true
})
}
DoubleChestMenu.scala:
package com.danikvitek.politicscountry.ui.gui.prefab
import com.danikvitek.politicscountry.ui.gui.{Button, Menu}
import com.danikvitek.politicscountry.utils.Translation
import net.kyori.adventure.text.Component
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.{Bukkit, Material}
abstract class DoubleChestMenu(title: Component)
extends Menu(Bukkit.createInventory(null, 54, title)) {
def this(title: String) = this(Component text title)
for {
slot <- Seq(0, 1, 2, 6, 7, 8, 9, 17, 36, 44, 45, 46, 47, 51, 52, 53)
} setButton(slot, new Button(Material.BLUE_STAINED_GLASS_PANE, " ") {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = event setCancelled true
})
}
Status.scala:
package com.danikvitek.politicscountry.ui.gui.prefab
import com.danikvitek.politicscountry.gameplay.residency.Resident
import com.danikvitek.politicscountry.ui.gui.{Button, Menu, MenuHandler}
import com.danikvitek.politicscountry.utils.{ItemBuilder, Translation}
import com.danikvitek.politicscountry.api.controller.ResidentManager
import com.danikvitek.politicscountry.data.model.FormationType
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.{NamedTextColor, TextColor}
import net.kyori.adventure.util.RGBLike
import org.bukkit.{Bukkit, ChatColor, Material}
import org.bukkit.event.inventory.InventoryClickEvent
class Status(resident: Resident) extends SingleChestMenu(Translation.`status`) {
private val residentStatus = resident.getStatus
setButton(11, new Button(
new ItemBuilder(Material.RED_STAINED_GLASS_PANE)
.setDisplayName(Translation.`status - resident role`)
.addLore(Translation.`status - resident role map`(residentStatus._1))
.build
) {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = event setCancelled true
})
setButton(13, new Button(
new ItemBuilder(Material.RED_STAINED_GLASS_PANE)
.setDisplayName(Translation.`status - formation`)
.setLore {
val feud = residentStatus._2
val commonwealth = residentStatus._3
val state = residentStatus._4
val alliance = residentStatus._5
var lore = List.empty[String]
feud foreach { f =>
val typeName = f.typeName
.getOrElse(Translation.`status - formation type map`(FormationType.FEUD))
lore = lore :+
(Translation.`status - formation type color` + typeName + ": " + f.title)
}
commonwealth foreach { c =>
val typeName = c.typeName
.getOrElse(Translation.`status - formation type map`(FormationType.COMMONWEALTH))
lore = lore :+
(Translation.`status - formation type color` + typeName + ": " + c.title)
}
state foreach { s =>
val typeName = s.typeName
.getOrElse(Translation.`status - formation type map`(FormationType.STATE))
lore = lore :+
(Translation.`status - formation type color` + typeName + ": " + s.title)
}
alliance foreach { a =>
val typeName = a.typeName
.getOrElse(Translation.`status - formation type map`(FormationType.ALLIANCE))
lore = lore :+
(Translation.`status - formation type color` + typeName + ": " + a.title)
}
if lore.sizeIs == 0 then lore = lore :+
(Translation.`status - formation type color` + Translation.`status - formation type nothing`)
lore
}
.build
) {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = event setCancelled true
})
setButton(15, new Button(
new ItemBuilder(Material.RED_STAINED_GLASS_PANE)
.setDisplayName(Translation.`status - resident plots`)
.setLore {
val distances = residentStatus._6
.toSeq
.map { rp =>
val homePlotChunk = resident.feud.get.homePlot.chunk
math.hypot(homePlotChunk.getX - rp.chunk.getX, homePlotChunk.getZ - rp.chunk.getZ)
}
val chunks = residentStatus._6
.toSeq
.map(_.chunk)
var plotsList = (distances zip chunks)
.sortWith(_._1 < _._1)
.map(_._2)
.map { chunk =>
Translation.`status - resident plot color` + Translation.`status - plot at` +
s" (${chunk.getX}, ${chunk.getZ})"
}
if plotsList.sizeIs == 0 then plotsList = plotsList :+
(Translation.`status - resident plot color` + Translation.`status - no plots`)
plotsList
}
.build
) {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = event setCancelled true
})
setButton(19, new Button(
Material.YELLOW_STAINED_GLASS_PANE,
Translation.`menu - back`
) {
override def onClick(menu: Menu, event: InventoryClickEvent): Unit = {
event setCancelled true
val player = resident.player
MenuHandler closeMenu player
player performCommand "pmenu"
}
})
}
I need your help to implement the AWS map, I have created the Arn for all the required map functionality but I don't know how to enable the search box and its functionality.
Map --> implemented
Place index --> need help
Route calculator --> need help
Geofence collection --> need help
Tracker --> need help
sample code for your reference:
import React, { useEffect, useState } from "react";
import { createRequestTransformer } from "amazon-location-helpers";
import { ICredentials } from "#aws-amplify/core";
import Amplify,{ Auth } from "aws-amplify";
import ReactMapGL, { NavigationControl, ViewportProps } from "react-map-gl";
import "maplibre-gl/dist/maplibre-gl.css";
import amplifyConfig from "../aws-exports";
Amplify.configure(amplifyConfig);
// Replace with the name of the map that you created on the Amazon Location Service console: https://console.aws.amazon.com/location/maps/home
const mapName = "<MAP NAME>";
const Map = () => {
const [credentials, setCredentials] = useState<ICredentials>();
const [transformRequest, setRequestTransformer] = useState<Function>();
const [viewport, setViewport] = React.useState<Partial<ViewportProps>>({
longitude: -123.1187,
latitude: 49.2819,
zoom: 10,
});
useEffect(() => {
const fetchCredentials = async () => {
setCredentials(await Auth.currentUserCredentials());
};
fetchCredentials();
}, []);
// create a new transformRequest function whenever the credentials change
useEffect(() => {
const makeRequestTransformer = async () => {
if (credentials != null) {
const tr = await createRequestTransformer({
credentials,
region: amplifyConfig.aws_project_region,
});
// wrap the new value in an anonymous function to prevent React from recognizing it as a
// function and immediately calling it
setRequestTransformer(() => tr);
}
};
makeRequestTransformer();
}, [credentials]);
return (
<div>
{transformRequest ? (
<ReactMapGL
{...viewport}
width="100%"
height="100vh"
/** #ts-ignore */
transformRequest={transformRequest}
mapStyle={mapName}
onViewportChange={setViewport}
>
<div style={{ position: "absolute", left: 20, top: 20 }}>
<NavigationControl showCompass={false} />
</div>
</ReactMapGL>
) : (
<h1>Loading...</h1>
)}
</div>
);
};
export default Map;
reference image:
I don't know how to enable the tracker and place index functionality can I get anyone help on this. Thanks in advance.
import 'package:video_player/video_player.dart';
import 'package:flutter/material.dart';
void main() => runApp(VideoApp());
class VideoApp extends StatefulWidget {
#override
_VideoAppState createState() => _VideoAppState();
}
class _VideoAppState extends State<VideoApp> {
VideoPlayerController _controller;
#override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
});
}
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Video Demo',
home: Scaffold(
body: Center(
child: _controller.value.isInitialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: Container(),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
),
);
}
#override
void dispose() {
super.dispose();
_controller.dispose();
}
}
Even though I had tried adding the dependencies and change the video link to a YouTube link instead, it still the same and does not display the video. May I know how to solve this problem? There are a few errors, I listed it as below:
The method 'VideoPlayer' isn't defined for the type '_VideoAppState'
Undefined name 'VideoPlayerController'.
Undefined class 'VideoPlayerController'.
Target of URI doesn't exist: 'package:video_player/video_player.dart'
Pubspec.yml below
name: icseat
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
dio: ^4.0.0
file_picker: ^4.0.0
video_player:
advance_pdf_viewer: ^2.0.0
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
http: ^0.13.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- images/logoicseat.png
- images/person.png
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
#Tommie C. The below are the errors that I experienced when running the codes:
Launching lib\View\Video.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:57805/tl8ztZ-XWag=/ws
Syncing files to device sdk gphone x86 arm...
W/e.icseattestin( 4832): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
I/ExoPlayerImpl( 4832): Init bda4bd9 [ExoPlayerLib/2.14.1] [generic_x86_arm, sdk_gphone_x86_arm, Google, 30]
I/Choreographer( 4832): Skipped 54 frames! The application may be doing too much work on its main thread.
I/OpenGLRenderer( 4832): Davey! duration=921ms; Flags=0, IntendedVsync=313961916316, Vsync=314861916280, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=314868026700, AnimationStart=314868094000, PerformTraversalsStart=314871530500, DrawStart=314873232800, SyncQueued=314874438400, SyncStart=314875924800, IssueDrawCommandsStart=314875998400, SwapBuffers=314879263000, FrameCompleted=314885090400, DequeueBufferDuration=1230100, QueueBufferDuration=3509200, GpuCompleted=0,
I/TetheringManager( 4832): registerTetheringEventCallback:com.example.icseattesting
I/VideoCapabilities( 4832): Unsupported profile 4 for video/mp4v-es
I/OMXClient( 4832): IOmx service obtained
D/SurfaceUtils( 4832): connecting to surface 0xe4d1c578, reason connectToSurface
I/MediaCodec( 4832): [OMX.android.goldfish.h264.decoder] setting surface generation to 4947969
D/SurfaceUtils( 4832): disconnecting from surface 0xe4d1c578, reason connectToSurface(reconnect)
D/SurfaceUtils( 4832): connecting to surface 0xe4d1c578, reason connectToSurface(reconnect)
E/ACodec ( 4832): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec ( 4832): codec does not support config priority (err -1010)
D/SurfaceUtils( 4832): disconnecting from surface 0xe4d1c578, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils( 4832): connecting to surface 0xe4d1c578, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils( 4832): set up nativeWindow 0xe4d1c578 for 1280x720, color 0x13, rotation 0, usage 0x1002900
W/Gralloc4( 4832): allocator 3.x is not supported
Lost connection to device.
Update:
Nota Bene: In the sample below, you can comment out the line trying to load the srt subtitles file (closedCaptionFile: _loadCaptions,).
Change the following in your pubspec.yaml to video_player: ^2.1.15
Note - Also, are you trying to run this in iOS or Android? Make sure you open
the Runner.xcworkspace file and perform the standard Xcode routines. Make
sure that the Runner project and the pods project is visible. Try
running flutter build ios from the terminal.
Then re-run flutter pub get or click get Dependencies in the UI. I'd also make a demo project (stub - flutter create --org com.yoursite stub01) and add the sample provided to see if the online sample is working.
Original:
Here is the complete sample from the plugin website for the video_player. You can paste it into your environment to be certain that everything is working. You should also make sure that you are following the setup steps where you give your iOS/Android app permission to access the internet (see the installation notes on the readme section of the website). I'd also make sure to run flutter upgrade on your terminal.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: public_member_api_docs
/// An example of using the plugin, controlling lifecycle and playback of the
/// video.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
void main() {
runApp(
MaterialApp(
home: _App(),
),
);
}
class _App extends StatelessWidget {
#override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: Scaffold(
key: const ValueKey<String>('home_page'),
appBar: AppBar(
title: const Text('Video player example'),
actions: <Widget>[
IconButton(
key: const ValueKey<String>('push_tab'),
icon: const Icon(Icons.navigation),
onPressed: () {
Navigator.push<_PlayerVideoAndPopPage>(
context,
MaterialPageRoute<_PlayerVideoAndPopPage>(
builder: (BuildContext context) => _PlayerVideoAndPopPage(),
),
);
},
)
],
bottom: const TabBar(
isScrollable: true,
tabs: <Widget>[
Tab(
icon: Icon(Icons.cloud),
text: "Remote",
),
Tab(icon: Icon(Icons.insert_drive_file), text: "Asset"),
Tab(icon: Icon(Icons.list), text: "List example"),
],
),
),
body: TabBarView(
children: <Widget>[
_BumbleBeeRemoteVideo(),
_ButterFlyAssetVideo(),
_ButterFlyAssetVideoInList(),
],
),
),
);
}
}
class _ButterFlyAssetVideoInList extends StatelessWidget {
#override
Widget build(BuildContext context) {
return ListView(
children: <Widget>[
_ExampleCard(title: "Item a"),
_ExampleCard(title: "Item b"),
_ExampleCard(title: "Item c"),
_ExampleCard(title: "Item d"),
_ExampleCard(title: "Item e"),
_ExampleCard(title: "Item f"),
_ExampleCard(title: "Item g"),
Card(
child: Column(children: <Widget>[
Column(
children: <Widget>[
const ListTile(
leading: Icon(Icons.cake),
title: Text("Video video"),
),
Stack(
alignment: FractionalOffset.bottomRight +
const FractionalOffset(-0.1, -0.1),
children: <Widget>[
_ButterFlyAssetVideo(),
Image.asset('assets/flutter-mark-square-64.png'),
]),
],
),
])),
_ExampleCard(title: "Item h"),
_ExampleCard(title: "Item i"),
_ExampleCard(title: "Item j"),
_ExampleCard(title: "Item k"),
_ExampleCard(title: "Item l"),
],
);
}
}
/// A filler card to show the video in a list of scrolling contents.
class _ExampleCard extends StatelessWidget {
const _ExampleCard({Key? key, required this.title}) : super(key: key);
final String title;
#override
Widget build(BuildContext context) {
return Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: const Icon(Icons.airline_seat_flat_angled),
title: Text(title),
),
ButtonBar(
children: <Widget>[
TextButton(
child: const Text('BUY TICKETS'),
onPressed: () {
/* ... */
},
),
TextButton(
child: const Text('SELL TICKETS'),
onPressed: () {
/* ... */
},
),
],
),
],
),
);
}
}
class _ButterFlyAssetVideo extends StatefulWidget {
#override
_ButterFlyAssetVideoState createState() => _ButterFlyAssetVideoState();
}
class _ButterFlyAssetVideoState extends State<_ButterFlyAssetVideo> {
late VideoPlayerController _controller;
#override
void initState() {
super.initState();
_controller = VideoPlayerController.asset('assets/Butterfly-209.mp4');
_controller.addListener(() {
setState(() {});
});
_controller.setLooping(true);
_controller.initialize().then((_) => setState(() {}));
_controller.play();
}
#override
void dispose() {
_controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
padding: const EdgeInsets.only(top: 20.0),
),
const Text('With assets mp4'),
Container(
padding: const EdgeInsets.all(20),
child: AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
VideoPlayer(_controller),
_ControlsOverlay(controller: _controller),
VideoProgressIndicator(_controller, allowScrubbing: true),
],
),
),
),
],
),
);
}
}
class _BumbleBeeRemoteVideo extends StatefulWidget {
#override
_BumbleBeeRemoteVideoState createState() => _BumbleBeeRemoteVideoState();
}
class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
late VideoPlayerController _controller;
Future<ClosedCaptionFile> _loadCaptions() async {
final String fileContents = await DefaultAssetBundle.of(context)
.loadString('assets/bumble_bee_captions.srt');
return SubRipCaptionFile(fileContents);
}
#override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4',
// closedCaptionFile: _loadCaptions(),
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
_controller.addListener(() {
setState(() {});
});
_controller.setLooping(true);
_controller.initialize();
}
#override
void dispose() {
_controller.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: <Widget>[
Container(padding: const EdgeInsets.only(top: 20.0)),
const Text('With remote mp4'),
Container(
padding: const EdgeInsets.all(20),
child: AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
VideoPlayer(_controller),
ClosedCaption(text: _controller.value.caption.text),
_ControlsOverlay(controller: _controller),
VideoProgressIndicator(_controller, allowScrubbing: true),
],
),
),
),
],
),
);
}
}
class _ControlsOverlay extends StatelessWidget {
const _ControlsOverlay({Key? key, required this.controller})
: super(key: key);
static const _examplePlaybackRates = [
0.25,
0.5,
1.0,
1.5,
2.0,
3.0,
5.0,
10.0,
];
final VideoPlayerController controller;
#override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
AnimatedSwitcher(
duration: Duration(milliseconds: 50),
reverseDuration: Duration(milliseconds: 200),
child: controller.value.isPlaying
? SizedBox.shrink()
: Container(
color: Colors.black26,
child: Center(
child: Icon(
Icons.play_arrow,
color: Colors.white,
size: 100.0,
),
),
),
),
GestureDetector(
onTap: () {
controller.value.isPlaying ? controller.pause() : controller.play();
},
),
Align(
alignment: Alignment.topRight,
child: PopupMenuButton<double>(
initialValue: controller.value.playbackSpeed,
tooltip: 'Playback speed',
onSelected: (speed) {
controller.setPlaybackSpeed(speed);
},
itemBuilder: (context) {
return [
for (final speed in _examplePlaybackRates)
PopupMenuItem(
value: speed,
child: Text('${speed}x'),
)
];
},
child: Padding(
padding: const EdgeInsets.symmetric(
// Using less vertical padding as the text is also longer
// horizontally, so it feels like it would need more spacing
// horizontally (matching the aspect ratio of the video).
vertical: 12,
horizontal: 16,
),
child: Text('${controller.value.playbackSpeed}x'),
),
),
),
],
);
}
}
class _PlayerVideoAndPopPage extends StatefulWidget {
#override
_PlayerVideoAndPopPageState createState() => _PlayerVideoAndPopPageState();
}
class _PlayerVideoAndPopPageState extends State<_PlayerVideoAndPopPage> {
late VideoPlayerController _videoPlayerController;
bool startedPlaying = false;
#override
void initState() {
super.initState();
_videoPlayerController =
VideoPlayerController.asset('assets/Butterfly-209.mp4');
_videoPlayerController.addListener(() {
if (startedPlaying && !_videoPlayerController.value.isPlaying) {
Navigator.pop(context);
}
});
}
#override
void dispose() {
_videoPlayerController.dispose();
super.dispose();
}
Future<bool> started() async {
await _videoPlayerController.initialize();
await _videoPlayerController.play();
startedPlaying = true;
return true;
}
#override
Widget build(BuildContext context) {
return Material(
elevation: 0,
child: Center(
child: FutureBuilder<bool>(
future: started(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.data == true) {
return AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: VideoPlayer(_videoPlayerController),
);
} else {
return const Text('waiting for video to load');
}
},
),
),
);
}
}