Abstract antiping into its own function
This commit is contained in:
parent
346db118a4
commit
f05de5188c
|
@ -0,0 +1,13 @@
|
||||||
|
package civilengineering
|
||||||
|
|
||||||
|
class Util {
|
||||||
|
companion object {
|
||||||
|
const val ZWSP: Char = '\u200b'
|
||||||
|
|
||||||
|
//Inserts a zero-width space at index 1 in the string'
|
||||||
|
@JvmStatic
|
||||||
|
fun antiping(str: String): String {
|
||||||
|
return str[0].toString()+ZWSP+str.substring(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package civilengineering.eventhandlers
|
||||||
|
|
||||||
import civilengineering.CivilEngineering
|
import civilengineering.CivilEngineering
|
||||||
import civilengineering.CivilEngineeringConfig
|
import civilengineering.CivilEngineeringConfig
|
||||||
|
import civilengineering.Util
|
||||||
import civilengineering.bridge.ApiMessage
|
import civilengineering.bridge.ApiMessage
|
||||||
import civilengineering.bridge.MessageHandler
|
import civilengineering.bridge.MessageHandler
|
||||||
import civilengineering.cfg
|
import civilengineering.cfg
|
||||||
|
@ -13,9 +14,8 @@ class AdvancementEventHandler {
|
||||||
fun handleAdvancements(event: AdvancementEvent) {
|
fun handleAdvancements(event: AdvancementEvent) {
|
||||||
if(cfg!!.relay.advancements && event.advancement.display != null) {
|
if(cfg!!.relay.advancements && event.advancement.display != null) {
|
||||||
val zwsp: Char = '\u200B'
|
val zwsp: Char = '\u200B'
|
||||||
var player: String = event.entityPlayer.name
|
var player: String = Util.antiping(event.entityPlayer.name)
|
||||||
player = player[0].toString()+zwsp+player.substring(1) //antiping
|
|
||||||
//toString is necessary, otherwise the JVM thinks we're trying to do integer addition
|
|
||||||
MessageHandler.transmit(ApiMessage("Server",player+" has earned the advancement "+event.advancement.displayText.unformattedText))
|
MessageHandler.transmit(ApiMessage("Server",player+" has earned the advancement "+event.advancement.displayText.unformattedText))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package civilengineering.eventhandlers
|
package civilengineering.eventhandlers
|
||||||
|
|
||||||
|
import civilengineering.Util
|
||||||
import civilengineering.bridge.ApiMessage
|
import civilengineering.bridge.ApiMessage
|
||||||
import civilengineering.bridge.MessageHandler
|
import civilengineering.bridge.MessageHandler
|
||||||
import civilengineering.cfg
|
import civilengineering.cfg
|
||||||
|
@ -14,8 +15,7 @@ class DeathEventHandler {
|
||||||
val entity = event.entityLiving
|
val entity = event.entityLiving
|
||||||
if (entity is EntityPlayer) {
|
if (entity is EntityPlayer) {
|
||||||
var message: String = entity.getCombatTracker().deathMessage.unformattedText
|
var message: String = entity.getCombatTracker().deathMessage.unformattedText
|
||||||
message = message[0].toString() + '\u200b' + message.substring(1) //antiping
|
MessageHandler.transmit(ApiMessage(username = "Server", text = Util.antiping(message)))
|
||||||
MessageHandler.transmit(ApiMessage(username = "Server", text = message))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue