@@ -12,12 +12,13 @@ import java.util.regex.Pattern;
|
||||
import net.minecraft.EnumChatFormat;
|
||||
import net.minecraft.network.chat.ChatClickable;
|
||||
import net.minecraft.network.chat.ChatClickable.EnumClickAction;
|
||||
import net.minecraft.network.chat.ChatComponentText;
|
||||
import net.minecraft.network.chat.ChatHexColor;
|
||||
import net.minecraft.network.chat.ChatMessage;
|
||||
import net.minecraft.network.chat.ChatModifier;
|
||||
import net.minecraft.network.chat.ComponentContents;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.network.chat.IChatMutableComponent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public final class CraftChatMessage {
|
||||
@@ -49,7 +50,7 @@ public final class CraftChatMessage {
|
||||
private static final ChatModifier RESET = ChatModifier.EMPTY.withBold(false).withItalic(false).withUnderlined(false).withStrikethrough(false).withObfuscated(false);
|
||||
|
||||
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
|
||||
private IChatMutableComponent currentChatComponent = new ChatComponentText("");
|
||||
private IChatMutableComponent currentChatComponent = IChatBaseComponent.empty();
|
||||
private ChatModifier modifier = ChatModifier.EMPTY;
|
||||
private final IChatBaseComponent[] output;
|
||||
private int currentIndex;
|
||||
@@ -146,10 +147,10 @@ public final class CraftChatMessage {
|
||||
}
|
||||
|
||||
private void appendNewComponent(int index) {
|
||||
IChatBaseComponent addition = new ChatComponentText(message.substring(currentIndex, index)).setStyle(modifier);
|
||||
IChatBaseComponent addition = IChatBaseComponent.literal(message.substring(currentIndex, index)).setStyle(modifier);
|
||||
currentIndex = index;
|
||||
if (currentChatComponent == null) {
|
||||
currentChatComponent = new ChatComponentText("");
|
||||
currentChatComponent = IChatBaseComponent.empty();
|
||||
list.add(currentChatComponent);
|
||||
}
|
||||
currentChatComponent.append(addition);
|
||||
@@ -296,7 +297,7 @@ public final class CraftChatMessage {
|
||||
for (IChatBaseComponent c : component) {
|
||||
ChatModifier modi = c.getStyle();
|
||||
ChatHexColor color = modi.getColor();
|
||||
if (!c.getContents().isEmpty() || color != null) {
|
||||
if (c.getContents() != ComponentContents.EMPTY || color != null) {
|
||||
if (color != null) {
|
||||
if (color.format != null) {
|
||||
out.append(color.format);
|
||||
@@ -332,7 +333,7 @@ public final class CraftChatMessage {
|
||||
out.append(EnumChatFormat.OBFUSCATED);
|
||||
hadFormat = true;
|
||||
}
|
||||
c.visitSelf((x) -> {
|
||||
c.getContents().visit((x) -> {
|
||||
out.append(x);
|
||||
return Optional.empty();
|
||||
});
|
||||
@@ -340,22 +341,22 @@ public final class CraftChatMessage {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static IChatBaseComponent fixComponent(IChatBaseComponent component) {
|
||||
public static IChatBaseComponent fixComponent(IChatMutableComponent component) {
|
||||
Matcher matcher = LINK_PATTERN.matcher("");
|
||||
return fixComponent(component, matcher);
|
||||
}
|
||||
|
||||
private static IChatBaseComponent fixComponent(IChatBaseComponent component, Matcher matcher) {
|
||||
if (component instanceof ChatComponentText) {
|
||||
ChatComponentText text = ((ChatComponentText) component);
|
||||
String msg = text.getContents();
|
||||
private static IChatBaseComponent fixComponent(IChatMutableComponent component, Matcher matcher) {
|
||||
if (component.getContents() instanceof LiteralContents) {
|
||||
LiteralContents text = ((LiteralContents) component.getContents());
|
||||
String msg = text.text();
|
||||
if (matcher.reset(msg).find()) {
|
||||
matcher.reset();
|
||||
|
||||
ChatModifier modifier = text.getStyle();
|
||||
ChatModifier modifier = component.getStyle();
|
||||
List<IChatBaseComponent> extras = new ArrayList<IChatBaseComponent>();
|
||||
List<IChatBaseComponent> extrasOld = new ArrayList<IChatBaseComponent>(text.getSiblings());
|
||||
component = text = new ChatComponentText("");
|
||||
List<IChatBaseComponent> extrasOld = new ArrayList<IChatBaseComponent>(component.getSiblings());
|
||||
component = IChatBaseComponent.empty();
|
||||
|
||||
int pos = 0;
|
||||
while (matcher.find()) {
|
||||
@@ -365,11 +366,11 @@ public final class CraftChatMessage {
|
||||
match = "http://" + match;
|
||||
}
|
||||
|
||||
ChatComponentText prev = new ChatComponentText(msg.substring(pos, matcher.start()));
|
||||
IChatMutableComponent prev = IChatBaseComponent.literal(msg.substring(pos, matcher.start()));
|
||||
prev.setStyle(modifier);
|
||||
extras.add(prev);
|
||||
|
||||
ChatComponentText link = new ChatComponentText(matcher.group());
|
||||
IChatMutableComponent link = IChatBaseComponent.literal(matcher.group());
|
||||
ChatModifier linkModi = modifier.withClickEvent(new ChatClickable(EnumClickAction.OPEN_URL, match));
|
||||
link.setStyle(linkModi);
|
||||
extras.add(link);
|
||||
@@ -377,13 +378,13 @@ public final class CraftChatMessage {
|
||||
pos = matcher.end();
|
||||
}
|
||||
|
||||
ChatComponentText prev = new ChatComponentText(msg.substring(pos));
|
||||
IChatMutableComponent prev = IChatBaseComponent.literal(msg.substring(pos));
|
||||
prev.setStyle(modifier);
|
||||
extras.add(prev);
|
||||
extras.addAll(extrasOld);
|
||||
|
||||
for (IChatBaseComponent c : extras) {
|
||||
text.append(c);
|
||||
component.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,21 +393,21 @@ public final class CraftChatMessage {
|
||||
for (int i = 0; i < extras.size(); i++) {
|
||||
IChatBaseComponent comp = extras.get(i);
|
||||
if (comp.getStyle() != null && comp.getStyle().getClickEvent() == null) {
|
||||
extras.set(i, fixComponent(comp, matcher));
|
||||
extras.set(i, fixComponent(comp.copy(), matcher));
|
||||
}
|
||||
}
|
||||
|
||||
if (component instanceof ChatMessage) {
|
||||
Object[] subs = ((ChatMessage) component).getArgs();
|
||||
if (component.getContents() instanceof TranslatableContents) {
|
||||
Object[] subs = ((TranslatableContents) component.getContents()).getArgs();
|
||||
for (int i = 0; i < subs.length; i++) {
|
||||
Object comp = subs[i];
|
||||
if (comp instanceof IChatBaseComponent) {
|
||||
IChatBaseComponent c = (IChatBaseComponent) comp;
|
||||
if (c.getStyle() != null && c.getStyle().getClickEvent() == null) {
|
||||
subs[i] = fixComponent(c, matcher);
|
||||
subs[i] = fixComponent(c.copy(), matcher);
|
||||
}
|
||||
} else if (comp instanceof String && matcher.reset((String) comp).find()) {
|
||||
subs[i] = fixComponent(new ChatComponentText((String) comp), matcher);
|
||||
subs[i] = fixComponent(IChatBaseComponent.literal((String) comp), matcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
* @return string
|
||||
*/
|
||||
public String getMappingsVersion() {
|
||||
return "eaeedbff51b16ead3170906872fda334";
|
||||
return "7b9de0da1357e5b251eddde9aa762916";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,7 +303,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
return file.delete();
|
||||
}
|
||||
|
||||
private static final List<String> SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17", "1.18");
|
||||
private static final List<String> SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19");
|
||||
|
||||
@Override
|
||||
public void checkSupported(PluginDescriptionFile pdf) throws InvalidPluginException {
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.sounds.SoundCategory;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.DifficultyDamageScaler;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
@@ -36,6 +37,8 @@ import net.minecraft.world.level.material.FluidType;
|
||||
import net.minecraft.world.level.material.FluidTypes;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.ticks.LevelTickAccess;
|
||||
import net.minecraft.world.ticks.TickListEmpty;
|
||||
|
||||
@@ -97,7 +100,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Random getRandom() {
|
||||
public RandomSource getRandom() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@@ -117,7 +120,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gameEvent(Entity entity, GameEvent gameevent, BlockPosition blockposition) {
|
||||
public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||
|
||||
public final class RandomSourceWrapper implements RandomSource {
|
||||
|
||||
private final Random random;
|
||||
|
||||
public RandomSourceWrapper(Random random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomSource fork() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionalRandomFactory forkPositional() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setSeed(long seed) {
|
||||
random.setSeed(seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
return random.nextInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int bound) {
|
||||
return random.nextInt(bound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLong() {
|
||||
return random.nextLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextBoolean() {
|
||||
return random.nextBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
return random.nextFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
return random.nextDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized double nextGaussian() {
|
||||
return random.nextGaussian();
|
||||
}
|
||||
|
||||
public static final class RandomWrapper extends Random {
|
||||
|
||||
private final RandomSource random;
|
||||
|
||||
public RandomWrapper(RandomSource random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeed(long l) {
|
||||
random.setSeed(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
return random.nextInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int i) {
|
||||
return random.nextInt(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLong() {
|
||||
return random.nextLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextBoolean() {
|
||||
return random.nextBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
return random.nextFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
return random.nextDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextGaussian() {
|
||||
return random.nextGaussian();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int var0, int var1) {
|
||||
return random.nextInt(var0, var1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user