Converted versions command to Kotlin.
This commit is contained in:
parent
a798800198
commit
ad3a9907a3
3 changed files with 68 additions and 98 deletions
|
@ -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<String> 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<String> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
#Generated by the Semver Plugin for Gradle
|
#Generated by the Semver Plugin for Gradle
|
||||||
#Tue May 11 12:39:39 PDT 2021
|
#Tue May 11 13:27:24 PDT 2021
|
||||||
version.buildmeta=727
|
version.buildmeta=728
|
||||||
version.major=0
|
version.major=0
|
||||||
version.minor=8
|
version.minor=8
|
||||||
version.patch=0
|
version.patch=0
|
||||||
version.prerelease=beta
|
version.prerelease=beta
|
||||||
version.project=mobibot
|
version.project=mobibot
|
||||||
version.semver=0.8.0-beta+727
|
version.semver=0.8.0-beta+728
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue