mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-01 13:26:30 +00:00
Lots of cleanup
This commit is contained in:
@@ -112,10 +112,10 @@ public class EcoSkillsPlugin extends EcoPlugin {
|
||||
@Override
|
||||
protected List<Listener> loadListeners() {
|
||||
return Arrays.asList(
|
||||
new SkillLevellingListener(this),
|
||||
new SkillLevellingListener(),
|
||||
new SkillDisplayListener(this),
|
||||
new StatModifierListener(this),
|
||||
new DataListener(this),
|
||||
new StatModifierListener(),
|
||||
new DataListener(),
|
||||
new PlayerBlockListener(this),
|
||||
new EcoSkillsEventModifierHandler(this)
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.bukkit.entity.Projectile
|
||||
import org.bukkit.persistence.PersistentDataType
|
||||
import java.util.*
|
||||
|
||||
val expMultiplierCache = HashMap<UUID, Double>()
|
||||
val expMultiplierCache = mutableMapOf<UUID, Double>()
|
||||
val plugin: EcoSkillsPlugin = EcoSkillsPlugin.getInstance()
|
||||
|
||||
fun Player.getSkillExperienceMultiplier(): Double {
|
||||
|
||||
@@ -6,10 +6,8 @@ import com.willfp.eco.core.command.impl.Subcommand
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.ecoskills.data.LeaderboardHandler
|
||||
import com.willfp.ecoskills.getTotalSkillLevel
|
||||
import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
import kotlin.math.ceil
|
||||
|
||||
|
||||
class CommandTop(plugin: EcoPlugin) :
|
||||
@@ -21,40 +19,16 @@ class CommandTop(plugin: EcoPlugin) :
|
||||
) {
|
||||
override fun getHandler(): CommandHandler {
|
||||
return CommandHandler { sender: CommandSender, args: List<String> ->
|
||||
var page = args.firstOrNull()?.toIntOrNull() ?: 1
|
||||
val page = args.firstOrNull()?.toIntOrNull() ?: 1
|
||||
|
||||
val top = LeaderboardHandler.sortedLeaderboard
|
||||
|
||||
val maxPage = ceil(top.size / 10.0).toInt()
|
||||
if (maxPage < page) {
|
||||
page = maxPage
|
||||
}
|
||||
|
||||
if (page <= 0) {
|
||||
page = 1
|
||||
}
|
||||
|
||||
val pagePlayers = mutableListOf<OfflinePlayer>()
|
||||
|
||||
val start = (page - 1) * 10
|
||||
val end = start + 9
|
||||
|
||||
for (i in start..end) {
|
||||
if (i > top.size - 1) {
|
||||
break
|
||||
}
|
||||
|
||||
pagePlayers.add(top[i])
|
||||
}
|
||||
val top = LeaderboardHandler.getPage(page)
|
||||
|
||||
val messages = plugin.langYml.getStrings("top", false)
|
||||
val lines = mutableListOf<String>()
|
||||
|
||||
val useDisplayName = plugin.configYml.getBool("commands.top.use-display-name")
|
||||
|
||||
var rank = start + 1
|
||||
|
||||
for (player in pagePlayers) {
|
||||
for ((rank, player) in top) {
|
||||
var line = plugin.langYml.getString("top-line-format", false)
|
||||
.replace("%rank%", rank.toString())
|
||||
.replace("%level%", player.getTotalSkillLevel().toString())
|
||||
@@ -68,8 +42,6 @@ class CommandTop(plugin: EcoPlugin) :
|
||||
line = line.replace("%playername%", name)
|
||||
|
||||
lines.add(line)
|
||||
|
||||
rank++
|
||||
}
|
||||
|
||||
val linesIndex = messages.indexOf("%lines%")
|
||||
|
||||
@@ -3,10 +3,32 @@ package com.willfp.ecoskills.data
|
||||
import com.willfp.ecoskills.getTotalSkillLevel
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.OfflinePlayer
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
class LeaderboardHandler {
|
||||
companion object {
|
||||
val sortedLeaderboard = mutableListOf<OfflinePlayer>()
|
||||
|
||||
fun getPage(page: Int): MutableMap<Int, OfflinePlayer> {
|
||||
val maxPage = ceil(sortedLeaderboard.size / 10.0).toInt()
|
||||
val finalPage = max(1, max(page, maxPage))
|
||||
|
||||
val startIndex = (finalPage - 1) * 10
|
||||
val endIndex = min(startIndex + 9, sortedLeaderboard.size - 1)
|
||||
|
||||
val players = sortedLeaderboard.subList(startIndex, endIndex)
|
||||
val withRank = mutableMapOf<Int, OfflinePlayer>()
|
||||
|
||||
var rank = startIndex + 1
|
||||
for (player in players) {
|
||||
withRank[rank] = player
|
||||
rank++
|
||||
}
|
||||
|
||||
return withRank
|
||||
}
|
||||
}
|
||||
|
||||
class Runnable : java.lang.Runnable {
|
||||
@@ -19,9 +41,8 @@ class LeaderboardHandler {
|
||||
}
|
||||
|
||||
val temp2 = temp.toList().sortedBy { (_, value) -> value }.toMap()
|
||||
|
||||
for ((k, _) in temp2) {
|
||||
top.add(k)
|
||||
for (key in temp2.keys) {
|
||||
top.add(key)
|
||||
}
|
||||
|
||||
sortedLeaderboard.clear()
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.bukkit.event.block.BlockDropItemEvent
|
||||
class EffectBountifulHarvest: Effect(
|
||||
"bountiful_harvest"
|
||||
) {
|
||||
private val blockMap = HashMap<Location, Material>()
|
||||
private val blockMap = mutableMapOf<Location, Material>()
|
||||
|
||||
override fun formatDescription(string: String, level: Int): String {
|
||||
return string.replace("%chance%", NumberUtils.format(this.getChance(level)))
|
||||
@@ -92,7 +92,7 @@ class EffectBountifulHarvest: Effect(
|
||||
private fun getChance(level: Int): Double {
|
||||
var chance = config.getDouble("chance-per-level") * level
|
||||
|
||||
chance -= ((getMultiplier(level) - 2) * 100)
|
||||
chance -= (getMultiplier(level) - 2) * 100
|
||||
if (chance == 0.0) {
|
||||
chance = 100.0
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class EffectEndangering : Effect(
|
||||
return
|
||||
}
|
||||
|
||||
this.plugin.run {
|
||||
this.plugin.scheduler.run {
|
||||
victim.noDamageTicks = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class EffectPotionmaster : Effect(
|
||||
|
||||
val data = meta.basePotionData
|
||||
|
||||
val effects = HashMap<PotionEffectType, Int>()
|
||||
val effects = mutableMapOf<PotionEffectType, Int>()
|
||||
|
||||
if (data.type == PotionType.TURTLE_MASTER) {
|
||||
effects[PotionEffectType.SLOW] = 4
|
||||
@@ -129,7 +129,7 @@ class EffectPotionmaster : Effect(
|
||||
|
||||
val data = meta.basePotionData
|
||||
|
||||
val effects = HashMap<PotionEffectType, Int>()
|
||||
val effects = mutableMapOf<PotionEffectType, Int>()
|
||||
|
||||
if (data.type == PotionType.TURTLE_MASTER) {
|
||||
effects[PotionEffectType.SLOW] = 4
|
||||
|
||||
@@ -26,13 +26,12 @@ abstract class Skill(
|
||||
lateinit var description: String
|
||||
lateinit var gui: SkillGUI
|
||||
var maxLevel: Int = 50
|
||||
private val rewards: MutableList<SkillObjectReward>
|
||||
private val guiLoreCache = HashMap<Int, List<String>>()
|
||||
private val messagesCache = HashMap<Int, List<String>>()
|
||||
private val rewards = mutableListOf<SkillObjectReward>()
|
||||
private val guiLoreCache = mutableMapOf<Int, List<String>>()
|
||||
private val messagesCache = mutableMapOf<Int, List<String>>()
|
||||
|
||||
init {
|
||||
config = SkillConfig(this.id, this.javaClass, plugin)
|
||||
rewards = mutableListOf()
|
||||
|
||||
Skills.registerNewSkill(this)
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ class SkillGUI(
|
||||
val progressionOrder = "123456789abcdefghijklmnopqrstuvwxyz"
|
||||
val progressionPattern = plugin.configYml.getStrings("level-gui.progression-slots.pattern", false)
|
||||
|
||||
val progressionSlots: MutableMap<Int, Pair<Int, Int>> = HashMap()
|
||||
val progressionSlots = mutableMapOf<Int, Pair<Int, Int>>()
|
||||
|
||||
var x = 0
|
||||
for (row in progressionPattern) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class StatFerocity : Stat(
|
||||
return
|
||||
}
|
||||
|
||||
this.plugin.run {
|
||||
this.plugin.scheduler.run {
|
||||
victim.setMetadata("ferocity", plugin.metadataValueFactory.create(true))
|
||||
victim.noDamageTicks = 0
|
||||
victim.damage(event.damage, player)
|
||||
|
||||
Reference in New Issue
Block a user