-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
1,276 additions
and
1,806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 0 additions & 87 deletions
87
NWorldPermissions/src/top/nololiyt/worldpermissions/MarksManager.java
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
NWorldPermissions/src/top/nololiyt/worldpermissions/MarksManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package top.nololiyt.worldpermissions | ||
|
||
import org.bukkit.Location | ||
import org.bukkit.configuration.file.YamlConfiguration | ||
import top.nololiyt.worldpermissions.entities.DotDividedStringBuilder | ||
import top.nololiyt.worldpermissions.entities.StringPair | ||
|
||
import java.io.File | ||
import java.io.FileOutputStream | ||
import java.io.IOException | ||
import java.io.InputStream | ||
|
||
class MarksManager internal constructor(private val rootPlugin: RootPlugin) { | ||
|
||
private var configuration: YamlConfiguration? = null | ||
|
||
private val marksFile: File | ||
get() = File( | ||
rootPlugin.dataFolder.absolutePath, "marks.yml") | ||
|
||
init { | ||
val file = marksFile | ||
if (!file.exists()) { | ||
saveDefaultFile(file) | ||
} | ||
reloadConfiguration() | ||
} | ||
|
||
private fun saveDefaultFile(file: File) { | ||
val res = rootPlugin.getResource("marks.yml") | ||
try { | ||
file.parentFile.mkdirs() | ||
file.delete() | ||
file.createNewFile() | ||
val fileOutputStream = FileOutputStream(file) | ||
|
||
val buffer = ByteArray(4096) | ||
while (true) { | ||
val count = res!!.read(buffer, 0, buffer.size) | ||
fileOutputStream.write(buffer, 0, count) | ||
if (count < buffer.size) { | ||
break | ||
} | ||
} | ||
|
||
fileOutputStream.close() | ||
} catch (e: IOException) { | ||
e.printStackTrace() | ||
} | ||
|
||
} | ||
|
||
fun reloadConfiguration() { | ||
configuration = YamlConfiguration.loadConfiguration( | ||
marksFile) | ||
} | ||
|
||
fun setMark(name: String, mark: Location?) { | ||
configuration!!.set(name, mark) | ||
configuration!!.save(marksFile) | ||
} | ||
|
||
fun getMark(name: String): Location? { | ||
val oLocation = configuration!!.get(name) ?: return null | ||
return oLocation as Location | ||
} | ||
} |
Oops, something went wrong.