Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Make things actually work and add memory leak command #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'me.bristermitten.pdm' version '0.0.1'
}

group = 'at.helpch'
Expand Down Expand Up @@ -30,9 +31,23 @@ dependencies {
compileOnly 'me.clip:placeholderapi:2.10.6'
//katsumag - end
//BM start
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
pdm "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}//BM end

pdm {
version = '0.0.1-SNAPSHOT' //uses a slightly newer version of the runtime because Gradle Plugin Publishing is a bitch
}

jar.dependsOn project.tasks.getByName('pdm')

import org.apache.tools.ant.filters.ReplaceTokens

processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Tue Jun 30 21:19:32 BST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/at/helpch/hccce/HCCCE.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package at.helpch.hccce

import at.helpch.hccce.commands.LeakCommand
import at.helpch.hccce.commands.OnlineCommand
import me.bristermitten.pdm.PluginDependencyManager
import org.bukkit.plugin.java.JavaPlugin

class HCCCE : JavaPlugin() {

override fun onEnable() {
PluginDependencyManager(this).loadAllDependencies().join()
firstTime()
this.getCommand("online")?.setExecutor(OnlineCommand())
getCommand("leak")?.setExecutor(LeakCommand(this))
}
}
34 changes: 34 additions & 0 deletions src/main/kotlin/at/helpch/hccce/commands/LeakCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package at.helpch.hccce.commands

import org.bukkit.Bukkit
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.plugin.Plugin
import sun.misc.Unsafe

/**
* @author AlexL
*/
class LeakCommand(val plugin: Plugin) : CommandExecutor
{
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean
{
val clazz = Unsafe::class.java
val field = clazz.getDeclaredField("theUnsafe")
field.isAccessible = true
val unsafe = field.get(null) as Unsafe
//memory go brrr
Bukkit.getScheduler().runTaskTimer(plugin, Runnable {
pointers += unsafe.allocateMemory(50000000)
sender.sendMessage("le4k3d n00b")
}, 0L, 20L)
return true
}

companion object
{
@JvmStatic
val pointers = mutableListOf<Long>()
}
}
5 changes: 3 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: HCCCE
version: @version@
main: at.helpch.hccce.HCCCE
api-version: 1.15.2
api-version: 1.15
authors: [helpchat]
description: A community effort
website: https://helpch.at
Expand All @@ -15,4 +15,5 @@ commands:
# kali start
online:
description: get online player count
# kali end
# kali end
leak: {}