mirror of
https://github.com/darksaid98/nightcore-spigot.git
synced 2026-12-01 14:38:47 +00:00
added 1.21
This commit is contained in:
1 parent
bc8594db61
commit
8823d0eecd
10 files changed
+62
-13
No files matched your search
@@ -109,6 +109,6 @@ public class NightCore extends NightPlugin implements ImprovedCommands {
|
||||
if (nbt == null) return false;
|
||||
|
||||
ItemStack decompressed = ItemNbt.decompress(nbt);
|
||||
return decompressed != null && decompressed.getType() == testItem.getType();
|
||||
return decompressed != null && decompressed.isSimilar(testItem);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,8 @@ public class ChainedNode extends CommandNode {
|
||||
//System.out.println("context.getArgs() = " + Arrays.toString(context.getArgs()));
|
||||
//System.out.println("context.getIndex() = " + context.getIndex());
|
||||
if (context.getIndex() == context.getArgs().length - 1) {
|
||||
return new ArrayList<>(this.commandMap.keySet());
|
||||
return this.getChildrens().stream().filter(node -> node.hasPermission(context.getSender())).map(CommandNode::getName).toList();
|
||||
//return new ArrayList<>(this.commandMap.keySet());
|
||||
}
|
||||
if (context.getIndex() >= context.getArgs().length) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -324,7 +324,7 @@ public class FileConfig extends YamlConfiguration {
|
||||
else {
|
||||
String headTexture = this.getString(path + "Head_Texture", "");
|
||||
if (!headTexture.isEmpty()) {
|
||||
Plugins.CORE.warn("'Head_Texture' itemstack option is deprecated and will be removed soon. Please, use 'SkinURL' option instead.");
|
||||
Plugins.CORE.warn("'Head_Texture' itemstack option is deprecated and will be removed soon. Please, use 'SkinURL' option instead. Caused by: " + file.getPath());
|
||||
ItemUtil.setSkullTexture(item, headTexture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class Colorizer {
|
||||
}
|
||||
}
|
||||
|
||||
return tagPlainHex(builder.toString());
|
||||
return builder.toString();//tagPlainHex(builder.toString());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -153,8 +153,9 @@ public class Colorizer {
|
||||
while ((index = builder.toString().indexOf("#", lastIndex)) >= 0) {
|
||||
lastIndex = index + 1;
|
||||
|
||||
if (builder.length() < 7) break;
|
||||
//if (builder.length() < 7) break;
|
||||
if (index > 0 && builder.charAt(index - 1) == Tag.OPEN_BRACKET) continue;
|
||||
if (builder.length() < index + 7) break;
|
||||
|
||||
String sub = builder.substring(index, index + 7);
|
||||
try {
|
||||
|
||||
@@ -64,6 +64,8 @@ public class ItemUtil {
|
||||
if (item.getType() != Material.PLAYER_HEAD) return;
|
||||
if (!(item.getItemMeta() instanceof SkullMeta meta)) return;
|
||||
|
||||
String name = urlData.substring(0, 16);
|
||||
|
||||
if (!urlData.startsWith(TEXTURES_HOST)) {
|
||||
urlData = TEXTURES_HOST + urlData;
|
||||
}
|
||||
@@ -73,7 +75,7 @@ public class ItemUtil {
|
||||
// If no name, then meta#getOwnerProfile will return 'null' (wtf?)
|
||||
// sometimes swtiching to "new" spigot api is a pain.
|
||||
// why the hell i have to dig into nms to learn that...
|
||||
PlayerProfile profile = Bukkit.createPlayerProfile(uuid, urlData.substring(0, 16));
|
||||
PlayerProfile profile = Bukkit.createPlayerProfile(uuid, name);
|
||||
URL url = new URL(urlData);
|
||||
PlayerTextures textures = profile.getTextures();
|
||||
textures.setSkin(url);
|
||||
|
||||
@@ -59,15 +59,32 @@ public class LocationUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public static Location getCenter(@NotNull Location location) {
|
||||
return getCenter(location, true);
|
||||
return setCenter3D(location);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public static Location getCenter(@NotNull Location location, boolean doVertical) {
|
||||
return setCenter(location, doVertical);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Location setCenter2D(@NotNull Location location) {
|
||||
return setCenter(location, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Location setCenter3D(@NotNull Location location) {
|
||||
return setCenter(location, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Location setCenter(@NotNull Location location, boolean is3D) {
|
||||
//Location centered = location.clone();
|
||||
location.setX(location.getBlockX() + 0.5);
|
||||
location.setY(location.getBlockY() + (doVertical ? 0.5 : 0));
|
||||
location.setY(location.getBlockY() + (is3D ? 0.5 : 0));
|
||||
location.setZ(location.getBlockZ() + 0.5);
|
||||
return location;
|
||||
}
|
||||
|
||||
@@ -3,16 +3,18 @@ package su.nightexpress.nightcore.util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum Version {
|
||||
|
||||
V1_18_R2("1.18.2"),
|
||||
V1_18_R2("1.18.2", true),
|
||||
V1_19_R3("1.19.4"),
|
||||
V1_20_R1("1.20.1", true),
|
||||
V1_20_R2("1.20.2", true),
|
||||
V1_20_R3("1.20.4"),
|
||||
MC_1_20_6("1.20.6"),
|
||||
MC_1_21("1.21"),
|
||||
UNKNOWN("Unknown"),
|
||||
;
|
||||
|
||||
@@ -42,7 +44,7 @@ public enum Version {
|
||||
public static Version getCurrent() {
|
||||
if (current == null) {
|
||||
String protocol = Bukkit.getServer().getBukkitVersion();
|
||||
current = Stream.of(values()).filter(version -> protocol.startsWith(version.getLocalized())).findFirst().orElse(UNKNOWN);
|
||||
current = Stream.of(values()).sorted(Comparator.reverseOrder()).filter(version -> protocol.startsWith(version.getLocalized())).findFirst().orElse(UNKNOWN);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package su.nightexpress.nightcore.util.text;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.util.Version;
|
||||
import su.nightexpress.nightcore.util.text.tag.decorator.ColorDecorator;
|
||||
import su.nightexpress.nightcore.util.text.tag.decorator.Decorator;
|
||||
import su.nightexpress.nightcore.util.text.tag.decorator.GradientColorDecorator;
|
||||
@@ -81,7 +83,21 @@ public class TextGroup implements ComponentBuildable {
|
||||
//}
|
||||
});
|
||||
|
||||
return builder.build();
|
||||
return this.build(builder);
|
||||
}
|
||||
|
||||
private BaseComponent build(@NotNull ComponentBuilder builder) {
|
||||
if (Version.isAtLeast(Version.MC_1_20_6)) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
TextComponent base = new TextComponent();
|
||||
if (!builder.getParts().isEmpty()) {
|
||||
List<BaseComponent> cloned = new ArrayList<>(builder.getParts());
|
||||
cloned.replaceAll(BaseComponent::duplicate);
|
||||
base.setExtra(cloned);
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
private void countLength(@NotNull TextGroup parent, @NotNull AtomicInteger length) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TextRoot {
|
||||
}
|
||||
|
||||
public void setString(@NotNull String string) {
|
||||
string = Colorizer.plain(string);
|
||||
string = Colorizer.tagPlainHex(Colorizer.plain(string));
|
||||
|
||||
/*if (CoreConfig.LEGACY_COLOR_SUPPORT.get()) {
|
||||
TimedMatcher timedMatcher = TimedMatcher.create(Colorizer.PATTERN_HEX_LEGACY, string);
|
||||
|
||||
+11
-1
@@ -1,11 +1,13 @@
|
||||
package su.nightexpress.nightcore.util.text.tag.decorator;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.nightcore.util.Lists;
|
||||
import su.nightexpress.nightcore.util.Placeholders;
|
||||
import su.nightexpress.nightcore.util.Version;
|
||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,7 +27,15 @@ public class ShowTextDecorator implements Decorator {
|
||||
@NotNull
|
||||
public HoverEvent createEvent() {
|
||||
String fused = String.join(Placeholders.TAG_LINE_BREAK, this.text);
|
||||
Text text = new Text(NightMessage.parse(fused));
|
||||
BaseComponent component = NightMessage.parse(fused);
|
||||
|
||||
Text text;
|
||||
if (Version.isAtLeast(Version.MC_1_20_6)) {
|
||||
text = new Text(component);
|
||||
}
|
||||
else {
|
||||
text = new Text(new ComponentBuilder().append(component).create());
|
||||
}
|
||||
|
||||
return new HoverEvent(HoverEvent.Action.SHOW_TEXT, text);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user