Skip to content

Commit 13bdfb1

Browse files
committed
Merge branch 'master' into mc1.12.2-we6
2 parents cefac85 + 5ca9b99 commit 13bdfb1

28 files changed

Lines changed: 762 additions & 210 deletions

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ Bomberman
33

44
A Bukkit plugin for Minecraft which adds Bomberman.
55

6-
See more on the bukkit page:
7-
http://dev.bukkit.org/bukkit-plugins/bomberman/
6+
https://www.spigotmc.org/resources/bomberman.77616/
87

98
## Building
109

1110
To build bomberman, run
1211

13-
<code>./gradlew build</code>
12+
```shell
13+
# To build exactly as released
14+
./gradlew minify
15+
16+
# To skip shading and proguard
17+
# ./gradlew build
18+
```
19+
1420

1521
To have the built file automatically copied to a local testing minecraft server:
1622

build.gradle

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
dependencies {
6+
classpath 'com.guardsquare:proguard-gradle:7.1.0'
7+
}
8+
}
9+
110
plugins {
11+
id 'com.github.johnrengelman.shadow' version '7.1.0'
212
id 'java'
3-
id "org.jetbrains.kotlin.jvm" version "1.5.21"
4-
id 'idea'
13+
id "org.jetbrains.kotlin.jvm" version "1.5.31"
514
}
615
sourceCompatibility = JavaVersion.VERSION_1_8
716
targetCompatibility = JavaVersion.VERSION_1_8
817

918
group = 'io.github.mdsimmo'
10-
version = '0.5.0-1.12.2-R1'
19+
version = '0.6.4-1.12.2-R1'
1120

1221
repositories {
1322
mavenCentral()
@@ -20,11 +29,23 @@ repositories {
2029
// world edit repo
2130
url "https://maven.enginehub.org/repo"
2231
}
32+
maven {
33+
// PlaceholderAPI
34+
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
35+
}
36+
maven {
37+
name = "sonatype-oss-snapshots"
38+
url = "https://oss.sonatype.org/content/repositories/snapshots/"
39+
}
40+
maven {
41+
url 'https://libraries.minecraft.net/'
42+
}
2343
}
2444

2545
dependencies {
26-
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21'
46+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31'
2747
implementation "net.objecthunter:exp4j:0.4.8"
48+
//implementation "me.lucko:commodore:1.10"
2849

2950
compileOnly "org.bukkit:bukkit:1.12.2-R0.1-SNAPSHOT"
3051
testImplementation "org.bukkit:bukkit:1.12.2-R0.1-SNAPSHOT"
@@ -33,23 +54,45 @@ dependencies {
3354
compileOnly "com.sk89q.worldedit:worldedit-bukkit:6.1.5"
3455
testImplementation "com.sk89q.worldedit:worldedit-bukkit:6.1.5"
3556

57+
compileOnly 'me.clip:placeholderapi:2.10+'
58+
testImplementation 'me.clip:placeholderapi:2.10+'
59+
3660
testImplementation "junit:junit:4.13.+"
3761
testImplementation "org.mockito:mockito-core:3.3.+"
3862
}
39-
63+
shadowJar {
64+
relocate 'net.objecthunter', 'io.github.mdsimmo.bomberman.lib.net.objecthunter'
65+
//relocate 'me.lucko', 'io.github.mdsimmo.bomberman.lib.me.lucko'
66+
relocate 'com.mojang', 'io.github.mdsimmo.bomberman.lib.com.mojang'
67+
relocate 'kotlin', 'io.github.mdsimmo.bomberman.lib.kotlin'
68+
relocate 'org.jetbrains', 'io.github.mdsimmo.bomberman.lib.org.jetbrains'
69+
relocate 'org.intellij', 'io.github.mdsimmo.bomberman.lib.org.intellij'
70+
}
4071

4172
processResources {
4273
// auto assign values in the plugin.yml
43-
// Do not filter schematics as they get corrupted when trying to be read as text
44-
filesNotMatching(["**.schematic"]) {
74+
filesMatching("plugin.yml") {
4575
filter {
46-
line ->
47-
line
48-
.replace('${version}', version)
76+
line -> line.replace('${version}', version)
4977
}
5078
}
5179
}
5280

81+
task minify(type: proguard.gradle.ProGuardTask, dependsOn: shadowJar) {
82+
injars shadowJar.outputs.files
83+
outjars "build/libs/Bomberman-${version}-min.jar"
84+
85+
libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod"
86+
libraryjars "${System.getProperty('java.home')}/jmods/java.logging.jmod"
87+
libraryjars configurations.findByName('compileOnly').getFiles()
88+
89+
// only remove unused library code (mostly kotlin)
90+
keep "public class !io.github.mdsimmo.bomberman.lib.** { *; }"
91+
92+
// Don't rename anything
93+
dontobfuscate
94+
}
95+
5396
task clearOldPluginJar( type: Delete ) {
5497
description 'Deletes any old bomberman plugins from the server'
5598
if ( project.hasProperty("serverLocation" ) ) {
@@ -62,23 +105,15 @@ task clearOldPluginJar( type: Delete ) {
62105
task copyToServer(type: Copy, dependsOn: clearOldPluginJar ) {
63106
description 'Copies the plugin to the server'
64107
if ( project.hasProperty("serverLocation" ) ) {
65-
from jar
108+
from minify
66109
into "$serverLocation/plugins/update"
67110
}
68111
}
69112

70-
task install( dependsOn: [build, copyToServer] ) {
113+
task install( dependsOn: [minify, copyToServer] ) {
71114
description 'Compiles, tests and copies the code to the server'
72115
}
73116

74-
jar {
75-
from {
76-
configurations.runtimeClasspath.collect {
77-
it.isDirectory() ? it : zipTree(it)
78-
}
79-
}
80-
}
81-
82117
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
83118
sourceCompatibility = JavaVersion.VERSION_1_8
84119
targetCompatibility = JavaVersion.VERSION_1_8
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Thu Apr 16 19:13:08 AEST 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
31
distributionBase=GRADLE_USER_HOME
42
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
64
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package io.github.mdsimmo.bomberman
2+
3+
import io.github.mdsimmo.bomberman.events.BmGameListIntent
4+
import io.github.mdsimmo.bomberman.events.BmGameLookupIntent
5+
import io.github.mdsimmo.bomberman.messaging.Message
6+
import io.github.mdsimmo.bomberman.messaging.SenderWrapper
7+
import io.github.mdsimmo.bomberman.messaging.SimpleContext
8+
import me.clip.placeholderapi.expansion.PlaceholderExpansion
9+
import org.bukkit.entity.Player
10+
11+
class BmPlaceholder : PlaceholderExpansion() {
12+
13+
override fun getIdentifier(): String = "bomberman"
14+
15+
override fun getAuthor(): String = "mdsimmo"
16+
17+
override fun getVersion(): String = "internal"
18+
19+
override fun persist(): Boolean = true
20+
21+
override fun onPlaceholderRequest(player: Player?, params: String): String {
22+
val content = params.split('_')
23+
when (content.getOrNull(0)) {
24+
"info" -> {
25+
val gameName = content.getOrNull(1) ?: return "info <name> <stat>"
26+
val game = BmGameLookupIntent.find(gameName)
27+
return game?.format(content.drop(2).map { Message.of(it) }, false)?.toString() ?: ""
28+
}
29+
"msg" -> {
30+
return try {
31+
SimpleContext(params.substring("msg_".length), false)
32+
.with("games", BmGameListIntent.listGames())
33+
.let {
34+
if (player != null)
35+
it.with("player", SenderWrapper(player))
36+
else
37+
it
38+
}
39+
.format()
40+
.toString()
41+
} catch (e: RuntimeException) {
42+
Message.error(e.message ?: "Error").toString()
43+
}
44+
}
45+
else -> return "<info|msg> ..."
46+
}
47+
}
48+
49+
50+
}

src/main/java/io/github/mdsimmo/bomberman/Bomberman.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.bukkit.command.PluginCommand;
1010
import org.bukkit.configuration.file.FileConfiguration;
1111
import org.bukkit.configuration.serialization.ConfigurationSerialization;
12+
import org.bukkit.entity.Player;
1213
import org.bukkit.event.Listener;
1314
import org.bukkit.plugin.java.JavaPlugin;
1415

@@ -52,8 +53,11 @@ public void onEnable() {
5253
bukkitBmCmd.setExecutor(bmCmd);
5354
bukkitBmCmd.setTabCompleter(bmCmd);
5455

55-
Game.loadGames();
56+
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
57+
new BmPlaceholder().register();
58+
}
5659

60+
Game.loadGames();
5761
GamePlayer.setupLoginWatcher();
5862
}
5963

src/main/java/io/github/mdsimmo/bomberman/commands/BaseCommand.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BaseCommand : CommandGroup(null), TabCompleter, CommandExecutor {
1313

1414
init {
1515
addChildren(
16-
//DevInfo(this),
16+
// DevInfo(this),
1717
Configure(this),
1818
GameCreate(this),
1919
GameInfo(this),
@@ -23,7 +23,8 @@ class BaseCommand : CommandGroup(null), TabCompleter, CommandExecutor {
2323
RunStart(this),
2424
RunStop(this),
2525
GameList(this),
26-
GameReload(this)
26+
GameReload(this),
27+
UndoBuild(this)
2728
)
2829
}
2930

src/main/java/io/github/mdsimmo/bomberman/commands/Cmd.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ abstract class Cmd(protected var parent: Cmd?) : Formattable {
9898
return text.with("command", this)
9999
}
100100

101-
override fun format(args: List<Message>): Message {
101+
override fun format(args: List<Message>, elevated: Boolean): Message {
102102
return when (args.getOrElse(0) { "name" }.toString()) {
103103
"name" -> name()
104104
"path" -> Message.of(path())
@@ -108,15 +108,15 @@ abstract class Cmd(protected var parent: Cmd?) : Formattable {
108108
"description" -> description()
109109
"flags" -> CollectionWrapper(flags(Bukkit.getConsoleSender(), listOf(), mapOf())
110110
.map { flag -> object: Formattable {
111-
override fun format(args: List<Message>): Message {
111+
override fun format(args: List<Message>, elevated: Boolean): Message {
112112
return when ((args.firstOrNull() ?: "name").toString()) {
113113
"name" -> Message.of(flag)
114114
"ext" -> flagExtension(flag)
115115
"description" -> flagDescription(flag)
116116
else -> throw RuntimeException("Unknown flag value '" + args[0] + "'")
117117
}
118118
}
119-
} }).format(args.drop(1))
119+
} }).format(args.drop(1), elevated)
120120
else -> throw RuntimeException("Unknown command value '" + args[0] + "'")
121121
}
122122
}

src/main/java/io/github/mdsimmo/bomberman/commands/CommandGroup.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ abstract class CommandGroup(parent: Cmd?) : Cmd(parent) {
8888
}
8989
}
9090

91-
override fun format(args: List<Message>): Message {
91+
override fun format(args: List<Message>, elevated: Boolean): Message {
9292
return if (args.getOrNull(0).toString().equals("children", ignoreCase = true)) {
93-
CollectionWrapper(children).format(args.drop(1))
93+
CollectionWrapper(children).format(args.drop(1), elevated)
9494
} else {
95-
super.format(args)
95+
super.format(args, elevated)
9696
}
9797
}
9898
}

src/main/java/io/github/mdsimmo/bomberman/commands/Permissions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ enum class Permissions(val permission: String) : Permission {
1010
BASE("bomberman.bm"),
1111
CREATE("bomberman.create"),
1212
DELETE("bomberman.delete"),
13+
UNDO("bomberman.undo"),
1314
RELOAD("bomberman.reload"),
1415
CONFIGURE("bomberman.configure"),
1516
START("bomberman.start"),

src/main/java/io/github/mdsimmo/bomberman/commands/game/DevInfo.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.github.mdsimmo.bomberman.commands.Cmd
55
import io.github.mdsimmo.bomberman.commands.Permission
66
import io.github.mdsimmo.bomberman.commands.Permissions
77
import io.github.mdsimmo.bomberman.messaging.Message
8+
import io.github.mdsimmo.bomberman.messaging.SimpleContext
89
import org.bukkit.Bukkit
910
import org.bukkit.ChatColor
1011
import org.bukkit.command.CommandSender
@@ -18,7 +19,7 @@ class DevInfo(parent: Cmd) : Cmd(parent) {
1819

1920
override fun options(sender: CommandSender, args: List<String>): List<String> {
2021
return listOf("handlerlist", "handlercount", "handlerwatch", "nocancelled",
21-
"tasklist", "taskcount", "taskwatch", "watch")
22+
"tasklist", "taskcount", "taskwatch", "watch", "permissions")
2223
}
2324

2425
override fun run(sender: CommandSender, args: List<String>, flags: Map<String, String>): Boolean {
@@ -123,14 +124,24 @@ class DevInfo(parent: Cmd) : Cmd(parent) {
123124
sender.sendMessage("Watching for new tasks")
124125
true
125126
}
127+
"permissions" -> {
128+
if (args.size == 1) {
129+
sender.effectivePermissions.forEach {
130+
sender.sendMessage(" - ${it.permission}")
131+
}
132+
} else {
133+
sender.sendMessage(args[1] + " : " + sender.hasPermission(args[1]))
134+
}
135+
true
136+
}
126137
else -> {
127138
false
128139
}
129140
}
130141
}
131142

132143
override fun permission(): Permission {
133-
return Permissions.CREATE
144+
return Permissions.BASE
134145
}
135146

136147
override fun example(): Message {

0 commit comments

Comments
 (0)