Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feature/1.18
Dieser Commit ist enthalten in:
Commit
404613520f
@ -19,6 +19,9 @@ permissions:
|
|||||||
geyser.command.advancements:
|
geyser.command.advancements:
|
||||||
description: Shows the advancements of the player on the server.
|
description: Shows the advancements of the player on the server.
|
||||||
default: true
|
default: true
|
||||||
|
geyser.command.tooltips:
|
||||||
|
description: Toggles showing advanced tooltips on your items.
|
||||||
|
default: true
|
||||||
geyser.command.statistics:
|
geyser.command.statistics:
|
||||||
description: Shows the statistics of the player on the server.
|
description: Shows the statistics of the player on the server.
|
||||||
default: true
|
default: true
|
||||||
@ -36,4 +39,4 @@ permissions:
|
|||||||
default: false
|
default: false
|
||||||
geyser.command.version:
|
geyser.command.version:
|
||||||
description: Shows the current Geyser version and checks for updates.
|
description: Shows the current Geyser version and checks for updates.
|
||||||
default: op
|
default: op
|
||||||
|
@ -54,6 +54,7 @@ public abstract class CommandManager {
|
|||||||
registerCommand(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
|
registerCommand(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
|
||||||
registerCommand(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
|
registerCommand(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
|
||||||
registerCommand(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
|
registerCommand(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
|
||||||
|
registerCommand(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
|
||||||
if (GeyserImpl.getInstance().getPlatformType() == PlatformType.STANDALONE) {
|
if (GeyserImpl.getInstance().getPlatformType() == PlatformType.STANDALONE) {
|
||||||
registerCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
|
registerCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.geyser.command.defaults;
|
||||||
|
|
||||||
|
import org.geysermc.geyser.command.CommandSender;
|
||||||
|
import org.geysermc.geyser.command.GeyserCommand;
|
||||||
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.text.MinecraftLocale;
|
||||||
|
|
||||||
|
public class AdvancedTooltipsCommand extends GeyserCommand {
|
||||||
|
public AdvancedTooltipsCommand(String name, String description, String permission) {
|
||||||
|
super(name, description, permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(GeyserSession session, CommandSender sender, String[] args) {
|
||||||
|
if (session != null) {
|
||||||
|
String onOrOff = session.isAdvancedTooltips() ? "off" : "on";
|
||||||
|
session.setAdvancedTooltips(!session.isAdvancedTooltips());
|
||||||
|
session.sendMessage("§l§e" + MinecraftLocale.getLocaleString("debug.prefix", session.getLocale()) + " §r" + MinecraftLocale.getLocaleString("debug.advanced_tooltips." + onOrOff, session.getLocale()));
|
||||||
|
session.getInventoryTranslator().updateInventory(session, session.getPlayerInventory());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExecutableOnConsole() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBedrockOnly() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -462,6 +462,12 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||||||
|
|
||||||
private final Set<UUID> emotes;
|
private final Set<UUID> emotes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether advanced tooltips will be added to the player's items.
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private boolean advancedTooltips = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The thread that will run every 50 milliseconds - one Minecraft tick.
|
* The thread that will run every 50 milliseconds - one Minecraft tick.
|
||||||
*/
|
*/
|
||||||
|
@ -154,6 +154,9 @@ public abstract class ItemTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nbt = translateDisplayProperties(session, nbt, bedrockItem);
|
nbt = translateDisplayProperties(session, nbt, bedrockItem);
|
||||||
|
if (session.isAdvancedTooltips()) {
|
||||||
|
nbt = addAdvancedTooltips(nbt, session.getItemMappings().getMapping(stack), session.getLocale());
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(stack.getId(), stack.getAmount(), nbt);
|
ItemStack itemStack = new ItemStack(stack.getId(), stack.getAmount(), nbt);
|
||||||
|
|
||||||
@ -183,6 +186,41 @@ public abstract class ItemTranslator {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static CompoundTag addAdvancedTooltips(CompoundTag nbt, ItemMapping mapping, String language) {
|
||||||
|
CompoundTag newNbt = nbt;
|
||||||
|
if (newNbt == null) {
|
||||||
|
newNbt = new CompoundTag("nbt");
|
||||||
|
CompoundTag display = new CompoundTag("display");
|
||||||
|
display.put(new ListTag("Lore"));
|
||||||
|
newNbt.put(display);
|
||||||
|
}
|
||||||
|
CompoundTag compoundTag = newNbt.get("display");
|
||||||
|
if (compoundTag == null) {
|
||||||
|
compoundTag = new CompoundTag("display");
|
||||||
|
}
|
||||||
|
ListTag listTag = compoundTag.get("Lore");
|
||||||
|
|
||||||
|
if (listTag == null) {
|
||||||
|
listTag = new ListTag("Lore");
|
||||||
|
}
|
||||||
|
int maxDurability = mapping.getMaxDamage();
|
||||||
|
|
||||||
|
if (maxDurability != 0) {
|
||||||
|
int durability = maxDurability - ((IntTag) newNbt.get("Damage")).getValue();
|
||||||
|
if (durability != maxDurability) {
|
||||||
|
listTag.add(new StringTag("", "§r§f" + String.format(MessageTranslator.convertMessage("item.durability", language), durability, maxDurability)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
listTag.add(new StringTag("", "§r§8" + mapping.getJavaIdentifier()));
|
||||||
|
if (nbt != null) {
|
||||||
|
listTag.add(new StringTag("", "§r§8" + String.format(MessageTranslator.convertMessage("item.nbt_tags", language), nbt.size())));
|
||||||
|
}
|
||||||
|
compoundTag.put(listTag);
|
||||||
|
newNbt.put(compoundTag);
|
||||||
|
return newNbt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the Java NBT of canDestroy and canPlaceOn to its Bedrock counterparts.
|
* Translates the Java NBT of canDestroy and canPlaceOn to its Bedrock counterparts.
|
||||||
* In Java, this is treated as normal NBT, but in Bedrock, these arguments are extra parts of the item data itself.
|
* In Java, this is treated as normal NBT, but in Bedrock, these arguments are extra parts of the item data itself.
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 1138a64627dec66fdb7f33c922ff6cd5636ec30a
|
Subproject commit 1a50238c1c743579a1dbd93c57d02b5da3be14fa
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren