mirror of
https://github.com/Ajneb97/MineChess.git
synced 2024-11-25 08:35:11 +01:00
1.13.1
This commit is contained in:
parent
b7648cb5ca
commit
1a2e7044fe
@ -1,5 +1,5 @@
|
||||
main: mc.ajneb97.MineChess
|
||||
version: 1.12.1
|
||||
version: 1.13.1
|
||||
name: MineChess
|
||||
api-version: 1.13
|
||||
softdepend: [Multiverse-Core,HolographicDisplays,PlaceholderAPI]
|
||||
|
@ -20,7 +20,7 @@ public class Tablero {
|
||||
Material m = null;
|
||||
if(color.equals("b")) {
|
||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15")
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
m = Material.valueOf("WHITE_WOOL");
|
||||
}else {
|
||||
m = Material.WOOL;
|
||||
@ -37,7 +37,7 @@ public class Tablero {
|
||||
l.clone().add(2,0,2).getBlock().setType(m);
|
||||
}else {
|
||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15")
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
m = Material.valueOf("GRAY_WOOL");
|
||||
l.getBlock().setType(m);
|
||||
l.clone().add(1,0,0).getBlock().setType(m);
|
||||
|
@ -16,7 +16,7 @@ public class ActionBarAPI
|
||||
|
||||
public static void sendActionBar(Player player, String message)
|
||||
{
|
||||
if(Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
if(Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
TextComponent text_component = new TextComponent(message);
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, text_component);
|
||||
return;
|
||||
|
@ -8,6 +8,7 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -31,7 +32,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
*/
|
||||
public class FastBoard {
|
||||
|
||||
private static final Map<Class<?>, Field[]> PACKETS = new HashMap<>(8);
|
||||
private static final Map<Class<?>, Field[]> PACKETS = new HashMap<>(8);
|
||||
private static final String[] COLOR_CODES = Arrays.stream(ChatColor.values())
|
||||
.map(Object::toString)
|
||||
.toArray(String[]::new);
|
||||
@ -87,6 +88,9 @@ public class FastBoard {
|
||||
Field playerConnectionField = Arrays.stream(entityPlayerClass.getFields())
|
||||
.filter(field -> field.getType().isAssignableFrom(playerConnectionClass))
|
||||
.findFirst().orElseThrow(NoSuchFieldException::new);
|
||||
Method sendPacketMethod = Arrays.stream(playerConnectionClass.getMethods())
|
||||
.filter(m -> m.getParameterCount() == 1 && m.getParameterTypes()[0] == packetClass)
|
||||
.findFirst().orElseThrow(NoSuchMethodException::new);
|
||||
|
||||
MESSAGE_FROM_STRING = lookup.unreflect(craftChatMessageClass.getMethod("fromString", String.class));
|
||||
CHAT_COMPONENT_CLASS = FastReflection.nmsClass("network.chat", "IChatBaseComponent");
|
||||
@ -95,7 +99,7 @@ public class FastBoard {
|
||||
RESET_FORMATTING = FastReflection.enumValueOf(CHAT_FORMAT_ENUM, "RESET", 21);
|
||||
PLAYER_GET_HANDLE = lookup.findVirtual(craftPlayerClass, "getHandle", MethodType.methodType(entityPlayerClass));
|
||||
PLAYER_CONNECTION = lookup.unreflectGetter(playerConnectionField);
|
||||
SEND_PACKET = lookup.findVirtual(playerConnectionClass, "sendPacket", MethodType.methodType(void.class, packetClass));
|
||||
SEND_PACKET = lookup.unreflect(sendPacketMethod);
|
||||
PACKET_SB_OBJ = FastReflection.findPacketConstructor(packetSbObjClass, lookup);
|
||||
PACKET_SB_DISPLAY_OBJ = FastReflection.findPacketConstructor(packetSbDisplayObjClass, lookup);
|
||||
PACKET_SB_SCORE = FastReflection.findPacketConstructor(packetSbScoreClass, lookup);
|
||||
@ -414,7 +418,7 @@ public class FastBoard {
|
||||
}
|
||||
|
||||
if (checkMax && line >= COLOR_CODES.length - 1) {
|
||||
throw new IllegalArgumentException("Line number is too high: " + this.lines.size());
|
||||
throw new IllegalArgumentException("Line number is too high: " + line);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class TitleAPI implements Listener {
|
||||
public static void sendTitle(Player player, Integer fadeIn, Integer stay, Integer fadeOut, String title, String subtitle) {
|
||||
TitleSendEvent titleSendEvent = new TitleSendEvent(player, title, subtitle);
|
||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15")
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
if(title.isEmpty()) {
|
||||
title = " ";
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class InventarioCoronacion implements Listener {
|
||||
|
||||
//Torre
|
||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15")
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
item = new ItemStack(Material.valueOf("PLAYER_HEAD"),1);
|
||||
}else {
|
||||
item = new ItemStack(Material.SKULL_ITEM,1,(short) 3);
|
||||
@ -51,7 +51,7 @@ public class InventarioCoronacion implements Listener {
|
||||
|
||||
//Caballo
|
||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15")
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
item = new ItemStack(Material.valueOf("PLAYER_HEAD"),1);
|
||||
}else {
|
||||
item = new ItemStack(Material.SKULL_ITEM,1,(short) 3);
|
||||
@ -64,7 +64,7 @@ public class InventarioCoronacion implements Listener {
|
||||
|
||||
//Alfil
|
||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15")
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
item = new ItemStack(Material.valueOf("PLAYER_HEAD"),1);
|
||||
}else {
|
||||
item = new ItemStack(Material.SKULL_ITEM,1,(short) 3);
|
||||
@ -82,7 +82,7 @@ public class InventarioCoronacion implements Listener {
|
||||
|
||||
//Reina
|
||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") || Bukkit.getVersion().contains("1.15")
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
|| Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17") || Bukkit.getVersion().contains("1.18")) {
|
||||
item = new ItemStack(Material.valueOf("PLAYER_HEAD"),1);
|
||||
}else {
|
||||
item = new ItemStack(Material.SKULL_ITEM,1,(short) 3);
|
||||
|
@ -25,6 +25,7 @@ import mc.ajneb97.versiones.V1_16;
|
||||
import mc.ajneb97.versiones.V1_16_R2;
|
||||
import mc.ajneb97.versiones.V1_16_R3;
|
||||
import mc.ajneb97.versiones.V1_17;
|
||||
import mc.ajneb97.versiones.V1_18;
|
||||
import mc.ajneb97.versiones.V1_8_R1;
|
||||
import mc.ajneb97.versiones.V1_8_R2;
|
||||
import mc.ajneb97.versiones.V1_8_R3;
|
||||
@ -68,7 +69,8 @@ public class Utilidades {
|
||||
|
||||
}
|
||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES,ItemFlag.HIDE_ENCHANTS,ItemFlag.HIDE_UNBREAKABLE,ItemFlag.HIDE_POTION_EFFECTS);
|
||||
if(Bukkit.getVersion().contains("1.15") || Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")) {
|
||||
if(Bukkit.getVersion().contains("1.15") || Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")
|
||||
|| Bukkit.getVersion().contains("1.18")) {
|
||||
meta.setUnbreakable(true);
|
||||
}else {
|
||||
meta.spigot().setUnbreakable(true); //SOLO FUNCIONA CON SPIGOT
|
||||
@ -80,6 +82,10 @@ public class Utilidades {
|
||||
|
||||
public static void setSkullBlock(Location l, String id, String textura, int rot) {
|
||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
if(packageName.contains("1_18")){
|
||||
V1_18 u = new V1_18();
|
||||
u.setSkullBlock(l,id,textura,rot);
|
||||
}
|
||||
if(packageName.contains("1_17")){
|
||||
V1_17 u = new V1_17();
|
||||
u.setSkullBlock(l,id,textura,rot);
|
||||
@ -148,6 +154,10 @@ public class Utilidades {
|
||||
|
||||
public static void generarParticula(String particle, Location loc, float xOffset, float yOffset, float zOffset, float speed, int count, Player player) {
|
||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
if(packageName.contains("1_18")){
|
||||
V1_18 u = new V1_18();
|
||||
u.generarParticula(particle, loc, xOffset, yOffset, zOffset, speed, count, player);
|
||||
}
|
||||
if(packageName.contains("1_17")){
|
||||
V1_17 u = new V1_17();
|
||||
u.generarParticula(particle, loc, xOffset, yOffset, zOffset, speed, count, player);
|
||||
@ -245,6 +255,11 @@ public class Utilidades {
|
||||
|
||||
public static ItemStack getCabeza(ItemStack item, String id,String textura){
|
||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
if(packageName.contains("1_18")){
|
||||
V1_18 u = new V1_18();
|
||||
ItemStack stack = u.getCabeza(item,id,textura);
|
||||
return stack;
|
||||
}
|
||||
if(packageName.contains("1_17")){
|
||||
V1_17 u = new V1_17();
|
||||
ItemStack stack = u.getCabeza(item,id,textura);
|
||||
|
71
src/mc/ajneb97/versiones/V1_18.java
Normal file
71
src/mc/ajneb97/versiones/V1_18.java
Normal file
@ -0,0 +1,71 @@
|
||||
package mc.ajneb97.versiones;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
public class V1_18 {
|
||||
|
||||
public void generarParticula(String particle, Location loc, float xOffset, float yOffset, float zOffset, float speed, int count, Player player){
|
||||
player.spawnParticle(Particle.valueOf(particle),loc,count,xOffset,yOffset,zOffset,speed);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setSkullBlock(Location locBloque,String id,String textura,int rot) {
|
||||
locBloque.getBlock().setType(Material.valueOf("PLAYER_HEAD"));
|
||||
Skull skullBlock = (Skull) locBloque.getBlock().getState();
|
||||
//skullBlock.setSkullType(SkullType.PLAYER);
|
||||
if(rot == 8) {
|
||||
skullBlock.setRotation(BlockFace.NORTH);
|
||||
}
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", textura));
|
||||
|
||||
try {
|
||||
Field profileField = skullBlock.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(skullBlock, profile);
|
||||
}catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); }
|
||||
|
||||
skullBlock.update();
|
||||
}
|
||||
|
||||
public ItemStack getCabeza(ItemStack item, String id,String textura) {
|
||||
if (textura.isEmpty()) return item;
|
||||
|
||||
SkullMeta skullMeta = (SkullMeta) item.getItemMeta();
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", textura));
|
||||
|
||||
try {
|
||||
Method mtd = skullMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
|
||||
mtd.setAccessible(true);
|
||||
mtd.invoke(skullMeta, profile);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
item.setItemMeta(skullMeta);
|
||||
return item;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user