feat: home gui translated, fly cancel after disguise
This commit is contained in:
parent
dd35f38dc2
commit
c57400707e
11 changed files with 128 additions and 45 deletions
|
@ -122,6 +122,7 @@ public class AppearanceManager {
|
|||
private void respawnPlayer() {
|
||||
final World world = player.getWorld();
|
||||
final boolean wasFlying = player.isFlying();
|
||||
final boolean wasAllowedToFly = player.getAllowFlight();
|
||||
final WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn();
|
||||
respawn.setDimension(world);
|
||||
respawn.setSeed(world.getSeed());
|
||||
|
@ -130,8 +131,9 @@ public class AppearanceManager {
|
|||
respawn.setDifficulty(world.getDifficulty());
|
||||
respawn.setCopyMetadata(true);
|
||||
respawn.sendPacket(player);
|
||||
player.setFlying(wasFlying);
|
||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
player.setAllowFlight(wasAllowedToFly);
|
||||
player.setFlying(wasFlying);
|
||||
player.updateInventory(); // Marked as unstable.
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,15 @@ import xyz.atnrch.nicko.gui.items.home.AdminAccessItem;
|
|||
import xyz.atnrch.nicko.gui.items.home.ExitItem;
|
||||
import xyz.atnrch.nicko.gui.items.home.ResetItem;
|
||||
import xyz.atnrch.nicko.gui.items.home.SettingsAccessItem;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.xenondevs.invui.gui.Gui;
|
||||
import xyz.xenondevs.invui.window.Window;
|
||||
|
||||
public class HomeGUI {
|
||||
private final String title = "Nicko - Home";
|
||||
private final Player player;
|
||||
private final Gui gui;
|
||||
private final String title;
|
||||
|
||||
public HomeGUI(Player player) {
|
||||
final String[] dynamicStructure = new String[]{
|
||||
|
@ -26,16 +28,26 @@ public class HomeGUI {
|
|||
dynamicStructure[2] = dynamicStructure[2].replace("A", "#");
|
||||
}
|
||||
|
||||
final I18N i18n = new I18N(player);
|
||||
this.title = i18n.translatePrefixless(I18NDict.GUI.Home.TITLE);
|
||||
|
||||
final ExitItem exitItem = new ExitItem(player);
|
||||
final ResetItem resetItem = new ResetItem(player);
|
||||
final ChangeNameItem changeNameItem = new ChangeNameItem(player);
|
||||
final ChangeBothItem changeBothItem = new ChangeBothItem(player);
|
||||
final ChangeSkinItem changeSkinItem = new ChangeSkinItem(player);
|
||||
final SettingsAccessItem settingsAccessItem = new SettingsAccessItem(player);
|
||||
final AdminAccessItem adminAccessItem = new AdminAccessItem(player);
|
||||
|
||||
this.gui = Gui.normal()
|
||||
.setStructure(dynamicStructure)
|
||||
.addIngredient('E', exitItem.get())
|
||||
.addIngredient('R', new ResetItem())
|
||||
.addIngredient('N', new ChangeNameItem())
|
||||
.addIngredient('B', new ChangeBothItem())
|
||||
.addIngredient('S', new ChangeSkinItem(player))
|
||||
.addIngredient('P', new SettingsAccessItem())
|
||||
.addIngredient('A', new AdminAccessItem())
|
||||
.addIngredient('R', resetItem.get())
|
||||
.addIngredient('N', changeNameItem.get())
|
||||
.addIngredient('B', changeBothItem.get())
|
||||
.addIngredient('S', changeSkinItem.get())
|
||||
.addIngredient('P', settingsAccessItem.get())
|
||||
.addIngredient('A', adminAccessItem.get())
|
||||
.build();
|
||||
this.player = player;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
package xyz.atnrch.nicko.gui.items.appearance;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.atnrch.nicko.anvil.AnvilManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
public class ChangeBothItem extends SuppliedItem {
|
||||
public ChangeBothItem() {
|
||||
super(() -> {
|
||||
public class ChangeBothItem {
|
||||
private final I18N i18n;
|
||||
|
||||
public ChangeBothItem(Player player) {
|
||||
this.i18n = new I18N(player);
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final ItemBuilder builder = new ItemBuilder(Material.TOTEM_OF_UNDYING);
|
||||
builder.setDisplayName("§6Skin §fand §6name §fchange");
|
||||
builder.addLoreLines("§7Will open a GUI to change both your name and your skin.");
|
||||
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.CHANGE_BOTH);
|
||||
builder.setDisplayName(translation.getName());
|
||||
translation.getLore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
package xyz.atnrch.nicko.gui.items.appearance;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.atnrch.nicko.anvil.AnvilManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
public class ChangeNameItem extends SuppliedItem {
|
||||
public ChangeNameItem() {
|
||||
super(() -> {
|
||||
public class ChangeNameItem {
|
||||
private final I18N i18n;
|
||||
|
||||
public ChangeNameItem(Player player) {
|
||||
this.i18n = new I18N(player);
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final ItemBuilder builder = new ItemBuilder(Material.NAME_TAG);
|
||||
builder.setDisplayName("Change §6name");
|
||||
builder.addLoreLines("§7Will open a GUI to change your name only.");
|
||||
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.CHANGE_NAME);
|
||||
builder.setDisplayName(translation.getName());
|
||||
translation.getLore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
|
|
|
@ -3,15 +3,27 @@ package xyz.atnrch.nicko.gui.items.appearance;
|
|||
import xyz.atnrch.nicko.anvil.AnvilManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||
import xyz.xenondevs.invui.item.builder.SkullBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
public class ChangeSkinItem extends SuppliedItem {
|
||||
public class ChangeSkinItem {
|
||||
private final I18N i18n;
|
||||
private final Player player;
|
||||
|
||||
public ChangeSkinItem(Player player) {
|
||||
super(() -> {
|
||||
this.i18n = new I18N(player);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final SkullBuilder builder = new SkullBuilder(player.getName());
|
||||
builder.setDisplayName("Change §6skin");
|
||||
builder.addLoreLines("§7Will open a GUI to change your skin only.");
|
||||
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.CHANGE_SKIN);
|
||||
builder.setDisplayName(translation.getName());
|
||||
translation.getLore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
package xyz.atnrch.nicko.gui.items.home;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.atnrch.nicko.gui.AdminGUI;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
public class AdminAccessItem extends SuppliedItem {
|
||||
public AdminAccessItem() {
|
||||
super(() -> {
|
||||
public class AdminAccessItem {
|
||||
private final I18N i18n;
|
||||
|
||||
public AdminAccessItem(Player player) {
|
||||
this.i18n = new I18N(player);
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final ItemBuilder builder = new ItemBuilder(Material.COMMAND_BLOCK_MINECART);
|
||||
builder.setDisplayName("Administration panel");
|
||||
builder.addLoreLines("§7Configure and manage Nicko.");
|
||||
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.ADMIN);
|
||||
builder.setDisplayName(translation.getName());
|
||||
translation.getLore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.event.inventory.ClickType;
|
|||
import xyz.atnrch.nicko.appearance.AppearanceManager;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
@ -13,17 +14,22 @@ import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
|||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class ResetItem extends SuppliedItem {
|
||||
public ResetItem() {
|
||||
super(() -> {
|
||||
public class ResetItem {
|
||||
private final I18N i18n;
|
||||
|
||||
public ResetItem(Player player) {
|
||||
this.i18n = new I18N(player);
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final ItemBuilder builder = new ItemBuilder(Material.TNT);
|
||||
builder.setDisplayName("Reset appearance");
|
||||
builder.addLoreLines("§7Completely remove your disguise.");
|
||||
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.RESET);
|
||||
builder.setDisplayName(translation.getName());
|
||||
translation.getLore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}, (event) -> {
|
||||
final Player player = event.getPlayer();
|
||||
final I18N i18n = new I18N(player);
|
||||
|
||||
final ClickType clickType = event.getClickType();
|
||||
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||
final Optional<NickoProfile> optionalProfile = NickoProfile.get(player);
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
package xyz.atnrch.nicko.gui.items.home;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.atnrch.nicko.gui.SettingsGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.i18n.ItemTranslation;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
public class SettingsAccessItem extends SuppliedItem {
|
||||
public SettingsAccessItem() {
|
||||
super(() -> {
|
||||
public class SettingsAccessItem {
|
||||
private final I18N i18n;
|
||||
|
||||
public SettingsAccessItem(Player player) {
|
||||
this.i18n = new I18N(player);
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final ItemBuilder builder = new ItemBuilder(Material.COMPARATOR);
|
||||
builder.setDisplayName("Settings");
|
||||
builder.addLoreLines("§7Configure your experience.");
|
||||
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.SETTINGS);
|
||||
builder.setDisplayName(translation.getName());
|
||||
translation.getLore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
|
|
|
@ -74,6 +74,11 @@ public class I18NDict {
|
|||
|
||||
public static final String TITLE = HOME_KEY + "title";
|
||||
public static final String ADMIN = HOME_KEY + "admin";
|
||||
public static final String CHANGE_NAME = HOME_KEY + "change_name";
|
||||
public static final String CHANGE_SKIN = HOME_KEY + "change_skin";
|
||||
public static final String CHANGE_BOTH = HOME_KEY + "change_both";
|
||||
public static final String RESET = HOME_KEY + "reset";
|
||||
public static final String SETTINGS = HOME_KEY + "settings";
|
||||
}
|
||||
|
||||
public static class Settings {
|
||||
|
|
|
@ -41,7 +41,7 @@ gui:
|
|||
settings:
|
||||
name: "Settings"
|
||||
lore:
|
||||
- "Configure your experience."
|
||||
- "Fine tune your experience with Nicko."
|
||||
change_name:
|
||||
name: "§6Nickname §fchange"
|
||||
change_skin:
|
||||
|
@ -53,7 +53,7 @@ gui:
|
|||
lore:
|
||||
- "Completely remove your disguise."
|
||||
admin:
|
||||
gui_title: "Nicko > Administration"
|
||||
title: "Nicko > Administration"
|
||||
manage_cache:
|
||||
name: "Manage §6skin §fcache..."
|
||||
lore:
|
||||
|
@ -63,6 +63,7 @@ gui:
|
|||
lore:
|
||||
- "§7See players' disguise information."
|
||||
settings:
|
||||
title: "Nicko > Settings"
|
||||
language:
|
||||
name: "Language"
|
||||
lore:
|
||||
|
|
|
@ -41,7 +41,7 @@ gui:
|
|||
settings:
|
||||
name: "Paramètres"
|
||||
lore:
|
||||
- "Configurez votre expérience."
|
||||
- "Gérez votre expérience avec Nicko."
|
||||
change_name:
|
||||
name: "Changer le §6pseudo"
|
||||
change_skin:
|
||||
|
@ -49,20 +49,21 @@ gui:
|
|||
change_both:
|
||||
name: "Changer les §6deux"
|
||||
reset:
|
||||
name: "Réinitialiser l''apparence"
|
||||
name: "Réinitialiser l'apparence"
|
||||
lore:
|
||||
- "Supprime complètement votre déguisement."
|
||||
admin:
|
||||
title: "Nicko > Administration"
|
||||
manage_cache:
|
||||
name: "Gérer le cache d''§6apparences..."
|
||||
name: "Gérer le cache d'§6apparences..."
|
||||
lore:
|
||||
- "§7Accédez à la gestion du cache d''apparences."
|
||||
- "§7Accédez à la gestion du cache d'apparences."
|
||||
manage_player:
|
||||
name: "Vérifier un joueur..."
|
||||
lore:
|
||||
- "§7Vérifiez les informations de déguisement d'un joueur."
|
||||
settings:
|
||||
title: "Nicko > Paramètres"
|
||||
language:
|
||||
name: "Langage"
|
||||
lore:
|
||||
|
|
Loading…
Reference in a new issue