Update v5.19 & Optimization
This commit is contained in:
parent
0152bb05c7
commit
1d66c4ed8f
41
build.gradle
41
build.gradle
@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'me.skymc'
|
||||
version = '5.18'
|
||||
version = '5.19'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
@ -19,28 +19,42 @@ tasks.withType(ScalaCompile) {
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "http://ptms.ink:8081/repository/codemc-nms/" }
|
||||
maven { url "http://ptms.ink:8081/repository/maven-releases/" }
|
||||
maven { url "http://repo.extendedclip.com/content/repositories/placeholderapi/" }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
shadow(group: 'org.apache.cassandra', name: 'cassandra-all', version: '0.8.1') {
|
||||
shadow('org.apache.cassandra:cassandra-all:0.8.1') {
|
||||
exclude(module: 'slf4j-log4j12')
|
||||
exclude(module: 'log4j')
|
||||
}
|
||||
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8'
|
||||
compile group: 'org.ow2.asm', name: 'asm', version: '7.0-beta'
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
|
||||
compile subprojects
|
||||
shadow group: 'com.zaxxer', name: 'HikariCP', version: '3.1.0'
|
||||
shadow group: 'org.scala-lang', name: 'scala-library', version: '2.12.8'
|
||||
shadow group: 'me.clip', name: 'placeholderapi', version: '2.10.4'
|
||||
shadow group: 'com.google.inject', name: 'guice', version: '4.2.2'
|
||||
compile 'ink.ptms.core:v11200:11200:all'
|
||||
compile 'ink.ptms.core:v11500:11500:all'
|
||||
compile 'ink.ptms.core:v11400:11400:all'
|
||||
compile 'ink.ptms.core:v11300:11300:all'
|
||||
compile 'ink.ptms.core:v10800:10800:all'
|
||||
compile 'net.md_5.bungee:BungeeCord:1:all'
|
||||
compile 'org.apache.commons:commons-lang3:3.8'
|
||||
compile 'com.google.code.gson:gson:2.8.6'
|
||||
compile 'org.ow2.asm:asm:7.0-beta'
|
||||
shadow 'com.zaxxer:HikariCP:3.1.0'
|
||||
shadow 'com.google.inject:guice:4.2.2'
|
||||
shadow 'org.scala-lang:scala-library:2.12.8'
|
||||
shadow 'pw.yumc.Yum:Yum:1:all'
|
||||
shadow 'me.clip:placeholderapi:2.10.4'
|
||||
shadow 'net.milkbowl.vault:Vault:1:all'
|
||||
shadow 'me.skymc.taboolib:TabooLib:4.9:all'
|
||||
shadow 'us.myles.ViaVersion:ViaVersion:1:all'
|
||||
shadow 'protocolsupport:ProtocolSupport:1:all'
|
||||
shadow 'com.sk89q.worldedit:WorldEdit:7:all'
|
||||
shadow 'com.sk89q.worldguard:WorldGuard:7:all'
|
||||
shadow 'org.inventivetalent.bossbar:BossBar:1:all'
|
||||
shadow fileTree(dir: 'libs', includes: ['*.jar'])
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
|
||||
// 免得 MANIFEST.MF 里面刷一堆 lib 难看
|
||||
taskActions.removeIf { it.actionClassName.contains 'configureShadowTask' }
|
||||
|
||||
@ -48,7 +62,6 @@ shadowJar {
|
||||
it.include it.dependency('org.apache.commons:.*')
|
||||
it.include it.dependency('org.ow2.asm:.*')
|
||||
it.include it.dependency('com.google.code.gson:.*')
|
||||
it.include it.dependency('me.skymc:.*')
|
||||
}
|
||||
|
||||
relocate 'org.apache.commons', 'io.izzel.taboolib.internal.apache'
|
||||
@ -57,8 +70,6 @@ shadowJar {
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include '__resources__/version'
|
||||
include 'plugin.yml'
|
||||
|
@ -1,4 +1,3 @@
|
||||
rootProject.name = 'TabooLib'
|
||||
include 'injector'
|
||||
include 'module-ipc'
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.izzel.taboolib;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.izzel.taboolib.module.command.TCommandHandler;
|
||||
import io.izzel.taboolib.module.config.TConfig;
|
||||
@ -27,6 +28,7 @@ public abstract class PluginLoader {
|
||||
|
||||
private static List<PluginLoader> registerLoader = Lists.newArrayList();
|
||||
private static Set<String> plugins = Sets.newHashSet();
|
||||
private static Map<String, Object> redefine = Maps.newHashMap();
|
||||
|
||||
static {
|
||||
registerLoader.add(new PluginLoader() {
|
||||
@ -65,8 +67,6 @@ public abstract class PluginLoader {
|
||||
|
||||
@Override
|
||||
public void onStopping(Plugin plugin) {
|
||||
// 卸载语言文件
|
||||
TLocaleLoader.unload(plugin);
|
||||
// 保存数据
|
||||
Local.saveFiles(plugin.getName());
|
||||
Local.clearFiles(plugin.getName());
|
||||
@ -80,6 +80,8 @@ public abstract class PluginLoader {
|
||||
DBSource.getDataSource().entrySet().stream().filter(dataEntry -> dataEntry.getKey().getPlugin().equals(plugin)).map(Map.Entry::getKey).forEach(DBSource::closeDataSource);
|
||||
// 注销调度器
|
||||
Bukkit.getScheduler().cancelTasks(plugin);
|
||||
// 卸载语言文件
|
||||
TLocaleLoader.unload(plugin);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -140,4 +142,12 @@ public abstract class PluginLoader {
|
||||
public static boolean isPlugin(Plugin plugin) {
|
||||
return plugins.contains(plugin.getName());
|
||||
}
|
||||
|
||||
public static void redefine(Plugin origin, Object instance) {
|
||||
redefine.put(origin.getName(), instance);
|
||||
}
|
||||
|
||||
public static Object get(Plugin plugin) {
|
||||
return redefine.getOrDefault(plugin.getName(), plugin);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package io.izzel.taboolib.common.listener;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.izzel.taboolib.TabooLibAPI;
|
||||
import io.izzel.taboolib.module.db.local.Local;
|
||||
import io.izzel.taboolib.module.db.local.LocalPlayer;
|
||||
import io.izzel.taboolib.module.hologram.Hologram;
|
||||
import io.izzel.taboolib.module.hologram.THologram;
|
||||
import io.izzel.taboolib.module.inject.TListener;
|
||||
import io.izzel.taboolib.module.locale.TLocale;
|
||||
import io.izzel.taboolib.module.locale.logger.TLogger;
|
||||
@ -11,6 +14,7 @@ import io.izzel.taboolib.util.Files;
|
||||
import io.izzel.taboolib.util.item.Items;
|
||||
import io.izzel.taboolib.util.lite.Signs;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -46,6 +50,30 @@ public class ListenerCommand implements Listener {
|
||||
e.getPlayer().sendMessage("§8[§3§lTabooLib§8] §7FakeSign Lines: §f" + Arrays.toString(lines));
|
||||
});
|
||||
}
|
||||
if (e.getMessage().equalsIgnoreCase("/hologramTest") && e.getPlayer().hasPermission("*")) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage("§8[§3§lTabooLib§8] §7Hologram Test.");
|
||||
Location location = e.getPlayer().getEyeLocation().add(e.getPlayer().getLocation().getDirection());
|
||||
Hologram hologram = THologram.create(location, "TabooLib", e.getPlayer())
|
||||
.flash(Lists.newArrayList(
|
||||
"§bT§fabooLib",
|
||||
"§bTa§fbooLib",
|
||||
"§bTab§fooLib",
|
||||
"§bTabo§foLib",
|
||||
"§bTaboo§fLib",
|
||||
"§bTabooL§fib",
|
||||
"§bTabooLi§fb",
|
||||
"§bTabooLib",
|
||||
"§bTabooLi§fb",
|
||||
"§bTabooL§fib",
|
||||
"§bTaboo§fLib",
|
||||
"§bTabo§foLib",
|
||||
"§bTab§fooLib",
|
||||
"§bTa§fbooLib",
|
||||
"§bT§fabooLib",
|
||||
"§fTabooLib"
|
||||
), 1).deleteOn(30);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
@ -9,8 +9,7 @@ import java.util.Arrays;
|
||||
|
||||
public class TDependency {
|
||||
|
||||
// 阿里 http://maven.aliyun.com/nexus/content/groups/public
|
||||
public static final String MAVEN_REPO = "http://repo1.maven.org/maven2";
|
||||
public static final String MAVEN_REPO = "https://maven.aliyun.com/repository/central";
|
||||
|
||||
/**
|
||||
* 请求一个插件作为依赖,这个插件将会在所有已经添加的 Jenkins 仓库、Maven 仓库寻找
|
||||
|
@ -1,13 +1,16 @@
|
||||
package io.izzel.taboolib.module.hologram;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import io.izzel.taboolib.TabooLib;
|
||||
import io.izzel.taboolib.module.nms.NMS;
|
||||
import io.izzel.taboolib.module.packet.TPacketHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
@ -22,6 +25,7 @@ public class Hologram {
|
||||
private boolean deleted = false;
|
||||
private boolean autoDelete = false;
|
||||
private int viewDistance = 50;
|
||||
private Consumer<Player> event;
|
||||
|
||||
Hologram(Location location, String text, Player... viewers) {
|
||||
THologram.getHolograms().add(this);
|
||||
@ -42,6 +46,11 @@ public class Hologram {
|
||||
return this;
|
||||
}
|
||||
|
||||
// public Hologram onClick(Consumer<Player> event) {
|
||||
// this.event = event;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
public Hologram refresh() {
|
||||
if (deleted) {
|
||||
return this;
|
||||
@ -75,6 +84,14 @@ public class Hologram {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Hologram flash(List<String> text, int period) {
|
||||
for (int i = 0; i < text.size(); i++) {
|
||||
String line = text.get(i);
|
||||
Bukkit.getScheduler().runTaskLater(TabooLib.getPlugin(), () -> flash(line), period * i);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Hologram flash(String text) {
|
||||
if (deleted) {
|
||||
return this;
|
||||
@ -99,6 +116,11 @@ public class Hologram {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Hologram deleteOn(int delay) {
|
||||
Bukkit.getScheduler().runTaskLater(TabooLib.getPlugin(), this::delete, delay);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Hologram destroy() {
|
||||
if (deleted) {
|
||||
return this;
|
||||
@ -181,6 +203,10 @@ public class Hologram {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
public Consumer<Player> getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
@ -44,6 +44,15 @@ class THologramHandler implements Listener {
|
||||
learned = true;
|
||||
Bukkit.getScheduler().runTask(TabooLib.getPlugin(), () -> learn(player));
|
||||
}
|
||||
if (packet.is("PacketPlayInUseEntity")) {
|
||||
int id = packet.read("a", Integer.TYPE);
|
||||
for (Hologram hologram : THologram.getHolograms()) {
|
||||
HologramViewer viewer = hologram.getViewer(player);
|
||||
if (viewer != null && viewer.getId() == id) {
|
||||
hologram.getEvent().accept(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -134,7 +143,6 @@ class THologramHandler implements Listener {
|
||||
public static void learn(Player player) {
|
||||
player.getWorld().spawn(player.getLocation(), ArmorStand.class, c -> {
|
||||
learnTarget = c;
|
||||
learnTarget.setSmall(true);
|
||||
learnTarget.setMarker(true);
|
||||
learnTarget.setVisible(false);
|
||||
learnTarget.setCustomName(" ");
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.izzel.taboolib.module.inject;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.izzel.taboolib.PluginLoader;
|
||||
import io.izzel.taboolib.compat.kotlin.CompatKotlin;
|
||||
import io.izzel.taboolib.module.locale.logger.TLogger;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -43,13 +44,17 @@ public class TInjectHelper {
|
||||
// No Static
|
||||
else if (!Modifier.isStatic(field.getModifiers())) {
|
||||
// Main
|
||||
if (pluginClass.equals(plugin.getClass())) {
|
||||
instance.add(plugin);
|
||||
if (pluginClass.equals(PluginLoader.get(plugin).getClass())) {
|
||||
instance.add(PluginLoader.get(plugin));
|
||||
}
|
||||
// TInject
|
||||
else if (TInjectCreator.getInstanceMap().entrySet().stream().anyMatch(e -> e.getKey().getType().equals(pluginClass))) {
|
||||
TInjectCreator.getInstanceMap().entrySet().stream().filter(e -> e.getKey().getType().equals(pluginClass)).forEach(i -> instance.add(i.getValue().getInstance()));
|
||||
}
|
||||
// TListener
|
||||
else {
|
||||
instance.addAll(TListenerHandler.getInstance(plugin, pluginClass));
|
||||
}
|
||||
}
|
||||
// Nothing
|
||||
if (instance.isEmpty()) {
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
@ -39,8 +40,6 @@ public class TListenerHandler {
|
||||
/**
|
||||
* 初始化插件的所有监听器
|
||||
* 该操作会执行无参构造方法
|
||||
*
|
||||
* @param plugin 插件
|
||||
*/
|
||||
public static void setupListener(Plugin plugin) {
|
||||
for (Class<?> pluginClass : TabooLibLoader.getPluginClassSafely(plugin)) {
|
||||
@ -89,8 +88,6 @@ public class TListenerHandler {
|
||||
/**
|
||||
* 注册插件的所有监听器
|
||||
* 该操作会执行 TListener 注解中的 register() 对应方法
|
||||
*
|
||||
* @param plugin 插件
|
||||
*/
|
||||
public static void registerListener(Plugin plugin) {
|
||||
Optional.ofNullable(listeners.get(plugin.getName())).ifPresent(listeners -> {
|
||||
@ -141,8 +138,6 @@ public class TListenerHandler {
|
||||
/**
|
||||
* 注销插件的所有监听器
|
||||
* 该操作会执行 TListener 注解中的 cancel() 对应方法
|
||||
*
|
||||
* @param plugin 插件
|
||||
*/
|
||||
public static void cancelListener(Plugin plugin) {
|
||||
Optional.ofNullable(listeners.remove(plugin.getName())).ifPresent(listeners -> {
|
||||
@ -162,6 +157,11 @@ public class TListenerHandler {
|
||||
});
|
||||
}
|
||||
|
||||
public static List<Listener> getInstance(Plugin plugin, Class pluginClass) {
|
||||
List<Listener> list = TListenerHandler.listeners.get(plugin.getName());
|
||||
return list == null ? Collections.emptyList() : list.stream().filter(listener -> pluginClass.equals(listener.getClass())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static HashMap<String, List<Listener>> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ public class NMSImpl extends NMS {
|
||||
} else {
|
||||
attr = ((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).getItem().i();
|
||||
}
|
||||
((Multimap) attr).forEach((k, v) -> {
|
||||
((Multimap) attr).asMap().forEach((k, v) -> {
|
||||
Object nbt = net.minecraft.server.v1_12_R1.GenericAttributes.a((net.minecraft.server.v1_12_R1.AttributeModifier) v);
|
||||
list.add(new NBTAttribute(
|
||||
new UUID(((NBTTagCompound) nbt).getLong("UUIDMost"), ((NBTTagCompound) nbt).getLong("UUIDLeast")),
|
||||
|
@ -70,7 +70,7 @@ public class NBTCompound extends NBTBase implements Map<String, NBTBase> {
|
||||
if (element instanceof JsonObject) {
|
||||
JsonObject json = (JsonObject) element;
|
||||
// base
|
||||
if (json.has("type") && json.has("data") && json.size() == 2) {
|
||||
if (json.has("type") && json.has("data") && json.entrySet().size() == 2) {
|
||||
switch (NBTType.parse(json.get("type").getAsString())) {
|
||||
case BYTE:
|
||||
return new NBTBase(json.get("data").getAsByte());
|
||||
|
@ -11,6 +11,7 @@ import io.izzel.taboolib.module.nms.nbt.Attribute;
|
||||
import io.izzel.taboolib.module.nms.nbt.NBTBase;
|
||||
import io.izzel.taboolib.module.nms.nbt.NBTCompound;
|
||||
import io.izzel.taboolib.module.nms.nbt.NBTList;
|
||||
import io.izzel.taboolib.util.Reflection;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -75,7 +76,11 @@ public class Items {
|
||||
public static Material asMaterial(String args) {
|
||||
try {
|
||||
Material material = Material.getMaterial(args.toUpperCase());
|
||||
return material != null ? material : Material.getMaterial(Integer.valueOf(args));
|
||||
if (material != null) {
|
||||
return material;
|
||||
}
|
||||
Object getById = Reflection.invokeMethod(Material.class, "getMaterial", NumberConversions.toInt(args));
|
||||
return getById != null ? (Material) getById : null;
|
||||
} catch (Exception e) {
|
||||
return Material.STONE;
|
||||
}
|
||||
@ -101,7 +106,11 @@ public class Items {
|
||||
public static Enchantment asEnchantment(String enchant) {
|
||||
try {
|
||||
Enchantment enchantment = Enchantment.getByName(enchant);
|
||||
return enchantment != null ? enchantment : Enchantment.getById(Integer.valueOf(enchant));
|
||||
if (enchantment != null) {
|
||||
return enchantment;
|
||||
}
|
||||
Object getById = Reflection.invokeMethod(Enchantment.class, "getById", NumberConversions.toInt(enchant));
|
||||
return getById != null ? (Enchantment) getById : null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user