File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1
1
import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYaml
2
2
3
+ import java.nio.file.Files
4
+ import java.nio.file.StandardCopyOption
5
+
3
6
plugins {
4
7
java
5
8
`java- library`
@@ -94,3 +97,32 @@ publishing {
94
97
tasks.named(" publishMavenJavaPublicationToMavenLocal" ) {
95
98
dependsOn(tasks.named(" build" ))
96
99
}
100
+
101
+ val serverPropertiesFile = layout.projectDirectory.file(" run/server.properties" )
102
+ val backupPropertiesFile = layout.buildDirectory.file(" server.properties.backup" )
103
+
104
+ tasks.register(" backupServerProperties" ) {
105
+ doLast {
106
+ val source = serverPropertiesFile.asFile
107
+ val destination = backupPropertiesFile.get().asFile
108
+ if (source.exists()) {
109
+ Files .copy(source.toPath(), destination.toPath(), StandardCopyOption .REPLACE_EXISTING )
110
+ println (" Backed up server.properties to build directory." )
111
+ }
112
+ }
113
+ }
114
+
115
+ tasks.register(" restoreServerProperties" ) {
116
+ doLast {
117
+ val source = backupPropertiesFile.get().asFile
118
+ val destination = serverPropertiesFile.asFile
119
+ if (source.exists()) {
120
+ Files .copy(source.toPath(), destination.toPath(), StandardCopyOption .REPLACE_EXISTING )
121
+ }
122
+ }
123
+ }
124
+
125
+ tasks.named(" runServer" ) {
126
+ dependsOn(" backupServerProperties" )
127
+ finalizedBy(" restoreServerProperties" )
128
+ }
You can’t perform that action at this time.
0 commit comments