From ad3a9907a3eb7609736c860dd4838e6b2ca64203 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 11 May 2021 13:30:58 -0700 Subject: [PATCH] Converted versions command to Kotlin. --- .../erik/mobibot/commands/Versions.java | 95 ------------------- .../thauvin/erik/mobibot/commands/Versions.kt | 65 +++++++++++++ version.properties | 6 +- 3 files changed, 68 insertions(+), 98 deletions(-) delete mode 100644 src/main/java/net/thauvin/erik/mobibot/commands/Versions.java create mode 100644 src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java b/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java deleted file mode 100644 index a86493f..0000000 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Versions.java - * - * Copyright (c) 2004-2021, Erik C. Thauvin (erik@thauvin.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * Neither the name of this project nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package net.thauvin.erik.mobibot.commands; - -import net.thauvin.erik.mobibot.Mobibot; -import net.thauvin.erik.mobibot.ReleaseInfo; -import net.thauvin.erik.mobibot.Utils; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class Versions extends AbstractCommand { - private final List allVersions = - List.of("Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')', - "Platform: " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") - + " (" + System.getProperty("os.arch") + ')', - "Runtime: " + System.getProperty("java.runtime.name") - + ' ' + System.getProperty("java.runtime.version")); - - public Versions(@NotNull final Mobibot bot) { - super(bot); - } - - @NotNull - @Override - public String getName() { - return "versions"; - } - - - @NotNull - @Override - public List getHelp() { - return List.of("To view the versions data (bot, platform, java, etc.):", Utils.helpFormat("%c " + getName())); - } - - @Override - public boolean isOp() { - return true; - } - - @Override - public boolean isPublic() { - return false; - } - - @Override - public boolean isVisible() { - return true; - } - - @Override - public void commandResponse(@NotNull final String sender, - @NotNull final String login, - @NotNull final String args, - final boolean isOp, - final boolean isPrivate) { - if (isOp) { - getBot().sendList(sender, allVersions, 1, isPrivate); - } else { - getBot().helpDefault(sender, false, isPrivate); - } - - } -} diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt new file mode 100644 index 0000000..57cd79b --- /dev/null +++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/Versions.kt @@ -0,0 +1,65 @@ +/* + * Versions.kt + * + * Copyright (c) 2004-2021, Erik C. Thauvin (erik@thauvin.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of this project nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.thauvin.erik.mobibot.commands + +import net.thauvin.erik.mobibot.Mobibot +import net.thauvin.erik.mobibot.ReleaseInfo +import net.thauvin.erik.mobibot.Utils.helpFormat +import net.thauvin.erik.mobibot.Utils.isoLocalDate + +class Versions(bot: Mobibot) : AbstractCommand(bot) { + private val allVersions = listOf( + "Version: ${ReleaseInfo.VERSION} (" + isoLocalDate(ReleaseInfo.BUILDDATE) + ')', + "Platform: " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") + + " (" + System.getProperty("os.arch") + ')', + "Runtime: " + System.getProperty("java.runtime.name") + ' ' + System.getProperty("java.runtime.version") + ) + override val name = "versions" + override val help = listOf("To view the versions data (bot, platform, java, etc.):", helpFormat("%c $name")) + override val isOp = true + override val isPublic = false + override val isVisible = true + + override fun commandResponse( + sender: String, + login: String, + args: String, + isOp: Boolean, + isPrivate: Boolean + ) { + if (isOp) { + bot.sendList(sender, allVersions, 1, isPrivate) + } else { + bot.helpDefault(sender, false, isPrivate) + } + } +} diff --git a/version.properties b/version.properties index 596efc1..aeb3fb7 100644 --- a/version.properties +++ b/version.properties @@ -1,9 +1,9 @@ #Generated by the Semver Plugin for Gradle -#Tue May 11 12:39:39 PDT 2021 -version.buildmeta=727 +#Tue May 11 13:27:24 PDT 2021 +version.buildmeta=728 version.major=0 version.minor=8 version.patch=0 version.prerelease=beta version.project=mobibot -version.semver=0.8.0-beta+727 +version.semver=0.8.0-beta+728