Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2eb350977c | ||
|
|
8a89a63c5f | ||
|
|
5c26e6e782 | ||
|
|
f88b914fa6 | ||
|
|
15ff6b3ea3 | ||
|
|
b14eed696c | ||
|
|
cffae33c87 |
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.willfp.eco.core.Prerequisite;
|
||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@@ -19,11 +20,17 @@ import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.BOLD;
|
||||
import static net.md_5.bungee.api.ChatColor.COLOR_CHAR;
|
||||
import static net.md_5.bungee.api.ChatColor.ITALIC;
|
||||
import static net.md_5.bungee.api.ChatColor.MAGIC;
|
||||
import static net.md_5.bungee.api.ChatColor.STRIKETHROUGH;
|
||||
import static net.md_5.bungee.api.ChatColor.UNDERLINE;
|
||||
|
||||
/**
|
||||
* Utilities / API methods for strings.
|
||||
@@ -61,6 +68,22 @@ public class StringUtils {
|
||||
.hexColors()
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Color map.
|
||||
*/
|
||||
private static final Map<String, ChatColor> COLOR_MAP = new ImmutableMap.Builder<String, ChatColor>()
|
||||
.put("&l", BOLD)
|
||||
.put("&o", ITALIC)
|
||||
.put("&n", UNDERLINE)
|
||||
.put("&m", STRIKETHROUGH)
|
||||
.put("&k", MAGIC)
|
||||
.put("§l", BOLD)
|
||||
.put("§o", ITALIC)
|
||||
.put("§n", UNDERLINE)
|
||||
.put("§m", STRIKETHROUGH)
|
||||
.put("§k", MAGIC)
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Format a list of strings.
|
||||
* <p>
|
||||
@@ -251,9 +274,9 @@ public class StringUtils {
|
||||
if (option == FormatOption.WITH_PLACEHOLDERS) {
|
||||
processedMessage = PlaceholderManager.translatePlaceholders(processedMessage, player);
|
||||
}
|
||||
processedMessage = ChatColor.translateAlternateColorCodes('&', processedMessage);
|
||||
processedMessage = translateGradients(processedMessage);
|
||||
processedMessage = translateHexColorCodes(processedMessage);
|
||||
processedMessage = ChatColor.translateAlternateColorCodes('&', processedMessage);
|
||||
if (Prerequisite.HAS_PAPER.isMet()) {
|
||||
processedMessage = translateMiniMessage(processedMessage);
|
||||
}
|
||||
@@ -293,26 +316,12 @@ public class StringUtils {
|
||||
@NotNull final Color end) {
|
||||
String processedString = string;
|
||||
List<ChatColor> modifiers = new ArrayList<>();
|
||||
if (processedString.contains("&l")) {
|
||||
modifiers.add(ChatColor.BOLD);
|
||||
for (Map.Entry<String, ChatColor> entry : COLOR_MAP.entrySet()) {
|
||||
if (processedString.contains(entry.getKey())) {
|
||||
modifiers.add(entry.getValue());
|
||||
}
|
||||
processedString = processedString.replace(entry.getKey(), "");
|
||||
}
|
||||
if (processedString.contains("&o")) {
|
||||
modifiers.add(ChatColor.ITALIC);
|
||||
}
|
||||
if (processedString.contains("&n")) {
|
||||
modifiers.add(ChatColor.UNDERLINE);
|
||||
}
|
||||
if (processedString.contains("&m")) {
|
||||
modifiers.add(ChatColor.STRIKETHROUGH);
|
||||
}
|
||||
if (processedString.contains("&k")) {
|
||||
modifiers.add(ChatColor.MAGIC);
|
||||
}
|
||||
processedString = processedString.replace("&l", "");
|
||||
processedString = processedString.replace("&o", "");
|
||||
processedString = processedString.replace("&n", "");
|
||||
processedString = processedString.replace("&k", "");
|
||||
processedString = processedString.replace("&m", "");
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
ChatColor[] colors = getGradientColors(start, end, processedString.length());
|
||||
|
||||
@@ -147,6 +147,7 @@ abstract class EcoSpigotPlugin : EcoPlugin(
|
||||
IntegrationLoader("NoCheatPlus") { AnticheatManager.register(this, AnticheatNCP()) },
|
||||
IntegrationLoader("Spartan") { AnticheatManager.register(this, AnticheatSpartan()) },
|
||||
IntegrationLoader("Vulcan") { AnticheatManager.register(this, AnticheatVulcan()) },
|
||||
IntegrationLoader("Alice") { AnticheatManager.register(this, AnticheatAlice()) },
|
||||
|
||||
// Custom Items
|
||||
IntegrationLoader("Oraxen") { CustomItemsManager.register(CustomItemsOraxen()) },
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.comphenix.protocol.events.PacketEvent
|
||||
import com.willfp.eco.core.AbstractPacketAdapter
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.display.Display
|
||||
import com.willfp.eco.spigot.display.frame.DisplayFrame
|
||||
import com.willfp.eco.spigot.display.frame.lastDisplayFrame
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
@@ -21,5 +23,7 @@ class PacketSetCreativeSlot(plugin: EcoPlugin) :
|
||||
itemStack!!
|
||||
)
|
||||
}
|
||||
|
||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.comphenix.protocol.events.PacketEvent
|
||||
import com.willfp.eco.core.AbstractPacketAdapter
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.display.Display
|
||||
import com.willfp.eco.spigot.display.frame.DisplayFrame
|
||||
import com.willfp.eco.spigot.display.frame.lastDisplayFrame
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
@@ -20,5 +22,7 @@ class PacketSetSlot(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketTyp
|
||||
item!!, player
|
||||
)
|
||||
}
|
||||
|
||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.display.Display
|
||||
import com.willfp.eco.core.fast.FastItemStack
|
||||
import com.willfp.eco.spigot.display.frame.DisplayFrame
|
||||
import com.willfp.eco.spigot.display.frame.HashedItem
|
||||
import com.willfp.eco.spigot.display.frame.lastDisplayFrame
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
@@ -24,27 +25,34 @@ class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, Packe
|
||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||
}
|
||||
|
||||
packet.itemListModifier.modify(0) { itemStacks: List<ItemStack>? ->
|
||||
packet.itemListModifier.modify(0) { itemStacks: MutableList<ItemStack>? ->
|
||||
if (itemStacks == null) {
|
||||
return@modify null
|
||||
}
|
||||
|
||||
if (this.getPlugin().configYml.getBool("use-display-frame") && windowId == 0) {
|
||||
val frameMap = mutableMapOf<Byte, Int>()
|
||||
val frameMap = mutableMapOf<Byte, HashedItem>()
|
||||
|
||||
for (index in itemStacks.indices) {
|
||||
frameMap[index.toByte()] = FastItemStack.wrap(itemStacks[index]).hashCode()
|
||||
frameMap[index.toByte()] =
|
||||
HashedItem(FastItemStack.wrap(itemStacks[index]).hashCode(), itemStacks[index])
|
||||
}
|
||||
|
||||
val newFrame = DisplayFrame(frameMap)
|
||||
|
||||
val changes = player.lastDisplayFrame.getChangedSlots(newFrame)
|
||||
val lastFrame = player.lastDisplayFrame
|
||||
|
||||
player.lastDisplayFrame = newFrame
|
||||
|
||||
val changes = lastFrame.getChangedSlots(newFrame)
|
||||
|
||||
for (index in changes) {
|
||||
Display.display(itemStacks[index.toInt()], player)
|
||||
}
|
||||
|
||||
for (index in (itemStacks.indices subtract changes)) {
|
||||
itemStacks[index.toInt()] = lastFrame.getItem(index.toByte()) ?: itemStacks[index.toInt()]
|
||||
}
|
||||
} else {
|
||||
itemStacks.forEach { Display.display(it, player) }
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package com.willfp.eco.spigot.display.frame
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
data class DisplayFrame(val items: Map<Byte, Int>) {
|
||||
data class HashedItem(val hash: Int, val item: ItemStack)
|
||||
|
||||
data class DisplayFrame(val items: Map<Byte, HashedItem>) {
|
||||
fun getChangedSlots(newFrame: DisplayFrame): List<Byte> {
|
||||
val changes = mutableListOf<Byte>()
|
||||
|
||||
for ((slot, hash) in newFrame.items) {
|
||||
if (items[slot] != hash) {
|
||||
for ((slot, data) in newFrame.items) {
|
||||
if (items[slot]?.hash != data.hash) {
|
||||
changes.add(slot)
|
||||
}
|
||||
}
|
||||
@@ -17,6 +20,10 @@ data class DisplayFrame(val items: Map<Byte, Int>) {
|
||||
return changes
|
||||
}
|
||||
|
||||
fun getItem(slot: Byte): ItemStack? {
|
||||
return items[slot]?.item
|
||||
}
|
||||
|
||||
companion object {
|
||||
val EMPTY = DisplayFrame(emptyMap())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.willfp.eco.spigot.integrations.anticheat
|
||||
|
||||
import com.willfp.eco.core.integrations.anticheat.AnticheatWrapper
|
||||
import me.nik.alice.api.events.AliceViolationEvent
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.Listener
|
||||
import java.util.*
|
||||
|
||||
class AnticheatAlice : AnticheatWrapper, Listener {
|
||||
private val exempt: MutableSet<UUID> = HashSet()
|
||||
|
||||
override fun getPluginName(): String {
|
||||
return "Alice"
|
||||
}
|
||||
|
||||
override fun exempt(player: Player) {
|
||||
exempt.add(player.uniqueId)
|
||||
}
|
||||
|
||||
override fun unexempt(player: Player) {
|
||||
exempt.remove(player.uniqueId)
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
private fun onViolate(event: AliceViolationEvent) {
|
||||
if (!exempt.contains(event.player.uniqueId)) {
|
||||
return
|
||||
}
|
||||
event.isCancelled = true
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ softdepend:
|
||||
- Oraxen
|
||||
- HeadDatabase
|
||||
- Multiverse-Inventories
|
||||
- Alice
|
||||
libraries:
|
||||
- 'org.reflections:reflections:0.9.12'
|
||||
- 'org.apache.maven:maven-artifact:3.0.3'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 6.11.1
|
||||
version = 6.11.2
|
||||
plugin-name = eco
|
||||
BIN
lib/alice-api-1.2.3.jar
Normal file
BIN
lib/alice-api-1.2.3.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user