Commit a0e8e88f authored by Moritz Sokoll's avatar Moritz Sokoll 🦀
Browse files

Inital Commit

parents
gradlew*
build/
.idea
.gradle
gradle/
# Minecraft Plugin
This repository contains the source code of my first minecraft plugin.
Features:
- permission list
- nickname
- playerlist on startup
- custom join message
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
repositories{
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
content {
includeGroup 'org.bukkit'
includeGroup 'org.spigotmc'
}
}
maven {
url = 'https://oss.sonatype.org/content/content/repositories/snapshots'
}
}
dependencies {
compileOnly 'org.bukkit:bukkit:1.14.4-R0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
kotlin.code.style=official
\ No newline at end of file
rootProject.name = 'kotlin'
package main
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.enchantments.Enchantment
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.plugin.java.JavaPlugin
import java.sql.Time
import java.time.Instant
public class Loader : JavaPlugin(), Listener, CommandExecutor {
override fun onEnable() {
Bukkit.getPluginManager().registerEvents(this, this)
}
@EventHandler
public fun joinEvent(event: PlayerJoinEvent) {
var players = Bukkit.getOnlinePlayers()
for (p in players) {
event.player.sendMessage("Currently there are " + players.size + " players online!")
}
}
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if (sender is Player) {
when(command.name){
"whoami" -> {
sender.sendMessage("name: " + sender.name)
sender.sendMessage("uuid: " + sender.uniqueId)
}
"permissions" -> {
if (args.isEmpty()) {
for (perm in sender.effectivePermissions) {
sender.sendMessage(perm.permission)
}
}
else {
var name = args[0]
for (p in server.onlinePlayers) {
if (p.name == name) {
for (perm in p.effectivePermissions) {
sender.sendMessage(perm.permission)
}
}
}
}
}
"opsword" -> {
var stack = ItemStack(Material.DIAMOND_SWORD, 1)
stack.addEnchantment(Enchantment.FIRE_ASPECT, 2)
var metadata = stack.itemMeta
metadata?.setDisplayName("Op Sword")
stack.itemMeta = metadata
sender.inventory.addItem(stack)
}
}
}
return true
}
}
\ No newline at end of file
name: kotlin
version: 1.0.0
description: you don know
main: main.Loader
commands:
whoami:
description: soos
usage: /<command>
permissions:
description: gets permissions of player
usage: /<command>
opsword:
description: gives the player an op sword
usage: /<command>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment