feat: 1.20/1.20.1 update

This commit is contained in:
ineanto 2023-06-28 13:22:48 +02:00
parent c66979133d
commit 50dd4c3adf
5 changed files with 64 additions and 37 deletions

View file

@ -41,14 +41,17 @@ public class AnvilManager {
.plugin(NickoBukkit.getInstance())
.itemLeft(getLeftItem(false))
.interactableSlots(AnvilGUI.Slot.OUTPUT)
.onComplete((completion) -> {
if (MojangUtils.isUsernameInvalid(completion.getText())) {
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
} else {
appearanceManager.setName(completion.getText());
openSkinAnvil();
return Collections.singletonList(AnvilGUI.ResponseAction.close());
.onClick((slot, snapshot) -> {
if (slot == AnvilGUI.Slot.OUTPUT) {
if (MojangUtils.isUsernameInvalid(snapshot.getText())) {
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
} else {
appearanceManager.setName(snapshot.getText());
openSkinAnvil();
return Collections.singletonList(AnvilGUI.ResponseAction.close());
}
}
return Collections.emptyList();
})
.text("New name...");
}
@ -58,14 +61,17 @@ public class AnvilManager {
.plugin(NickoBukkit.getInstance())
.itemLeft(getLeftItem(false))
.interactableSlots(AnvilGUI.Slot.OUTPUT)
.onComplete((completion) -> {
if (MojangUtils.isUsernameInvalid(completion.getText())) {
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
} else {
appearanceManager.setName(completion.getText());
final ActionResult<Void> actionResult = appearanceManager.updatePlayer(false);
return sendResultAndClose(actionResult);
.onClick((slot, snapshot) -> {
if (slot == AnvilGUI.Slot.OUTPUT) {
if (MojangUtils.isUsernameInvalid(snapshot.getText())) {
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
} else {
appearanceManager.setName(snapshot.getText());
final ActionResult<Void> actionResult = appearanceManager.updatePlayer(false);
return sendResultAndClose(actionResult);
}
}
return Collections.emptyList();
})
.text("New name...");
}
@ -75,14 +81,17 @@ public class AnvilManager {
.plugin(NickoBukkit.getInstance())
.itemLeft(getLeftItem(true))
.interactableSlots(AnvilGUI.Slot.OUTPUT)
.onComplete((completion) -> {
if (MojangUtils.isUsernameInvalid(completion.getText())) {
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
} else {
appearanceManager.setSkin(completion.getText());
final ActionResult<Void> actionResult = appearanceManager.updatePlayer(true);
return sendResultAndClose(actionResult);
.onClick((slot, snapshot) -> {
if (slot == AnvilGUI.Slot.OUTPUT) {
if (MojangUtils.isUsernameInvalid(snapshot.getText())) {
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
} else {
appearanceManager.setSkin(snapshot.getText());
final ActionResult<Void> actionResult = appearanceManager.updatePlayer(true);
return sendResultAndClose(actionResult);
}
}
return Collections.emptyList();
})
.text("New skin...");
}
@ -99,7 +108,7 @@ public class AnvilManager {
private ItemStack getLeftItem(boolean skin) {
final ItemStack item = new ItemStack(Material.PAPER);
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§0New " + (skin ? "skin" : "name") + "...");
if (meta != null) meta.setDisplayName("§0New " + (skin ? "skin" : "name") + "...");
item.setItemMeta(meta);
return item;
}

View file

@ -144,6 +144,7 @@ public class AppearanceManager {
private void respawnPlayer() {
final World world = player.getWorld();
final boolean wasFlying = player.isFlying();
final WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn();
respawn.setDimension(world);
respawn.setSeed(world.getSeed());
@ -152,8 +153,12 @@ public class AppearanceManager {
respawn.setDifficulty(world.getDifficulty());
respawn.setCopyMetadata(true);
respawn.sendPacket(player);
player.setFlying(wasFlying);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory();
}
@SuppressWarnings("deprecation")
private void updateTabList(WrappedGameProfile gameProfile, String displayName) {
final WrapperPlayerServerPlayerInfo add = new WrapperPlayerServerPlayerInfo();
if (MinecraftVersion.FEATURE_PREVIEW_UPDATE.atOrAbove()) {