Plugin Configuration and Code

master
Trivernis 5 years ago
parent 7b6eb3e703
commit cacca65d43

6
.gitignore vendored

@ -0,0 +1,6 @@
gradle
.gradle
.idea
build
out
gradlew*

@ -0,0 +1,2 @@
Manifest-Version: 1.0

@ -0,0 +1,56 @@
plugins {
id 'idea'
id 'org.jetbrains.kotlin.jvm' version '1.3.50'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
group 'net.trivernis'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url 'https://papermc.io/repo/repository/maven-public/'
}
maven {
url "https://hub.spigotmc.org/nexus/content/repositories/snapshots"
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven {
url "https://ci.ender.zone/plugin/repository/everything/"
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compileOnly "org.spigotmc:spigot-api:1.14.2-R0.1-SNAPSHOT"
compileOnly 'net.ess3:EssentialsX:2.16.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

@ -0,0 +1,2 @@
rootProject.name = 'superutils'

@ -0,0 +1,54 @@
package net.trivernis.superutils
import com.earth2me.essentials.Essentials
import com.earth2me.essentials.Trade
import org.bukkit.GameMode
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.event.player.PlayerTeleportEvent
import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.potion.PotionEffectType
class Main : JavaPlugin() {
override fun onEnable() {
}
override fun onDisable() {
}
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean {
if (sender is Player) {
if (command.name.equals("c", ignoreCase = true) && sender.hasPermission("superutils.c")) {
if (sender.gameMode != GameMode.SPECTATOR) {
sender.gameMode = GameMode.SPECTATOR
sender.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(1000000, 255))
} else {
sender.removePotionEffect(PotionEffectType.NIGHT_VISION)
sender.gameMode = GameMode.SURVIVAL
}
return true
} else if (command.name.equals("h", ignoreCase = true) && sender.hasPermission("superutils.h")) {
val essentials = getEssentials()
if (essentials != null) {
val essUser = essentials.getUser(sender);
val userHome = essUser.getHome("home");
essUser.teleport.teleport(userHome.block.location, null, PlayerTeleportEvent.TeleportCause.COMMAND);
essUser.sendMessage("You have been teleported home.");
}
}
}
return false;
}
private fun getEssentials(): Essentials? {
val essentials = server.pluginManager.getPlugin("Essentials");
return if (essentials != null && essentials is Essentials)
essentials;
else
null;
}
}

@ -0,0 +1,29 @@
main: net.trivernis.superutils.Main
name: SuperUtils
version: '1.0 SNAPSHOT'
description: Utility commands plugin.
author: Trivernis
website: trivernis.net
commands:
c:
description: spectator night vision
permission: superutils.c
permission-message: You do not have permission!
usage: /c
h:
description: teleport to default home
permission: superutils.h
permission-message: You do not have permission!
usage: /h
permissions:
superutils.c:
description: Allows c command
default: op
superutils.h:
description: Allow h command
default: op
superutils.*:
description: Wildcard permission
default: op
children:
superutils.c: true
Loading…
Cancel
Save