Compare commits
No commits in common. "7fe598539118a0d21290781c413a17f7d434c186" and "7fac9d027928049b7c77f238273626d6c9c7357c" have entirely different histories.
7fe5985391
...
7fac9d0279
8 changed files with 15 additions and 39 deletions
|
@ -33,7 +33,7 @@ dependencies {
|
||||||
paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT")
|
paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
compileOnly("me.clip:placeholderapi:2.11.5")
|
compileOnly("me.clip:placeholderapi:2.11.5")
|
||||||
compileOnly("net.kyori:adventure-api:4.21.0")
|
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||||
compileOnly("xyz.xenondevs.invui:invui-core:$invuiVersion")
|
compileOnly("xyz.xenondevs.invui:invui-core:$invuiVersion")
|
||||||
compileOnly("net.wesjd:anvilgui:1.10.4-SNAPSHOT")
|
compileOnly("net.wesjd:anvilgui:1.10.4-SNAPSHOT")
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.4.0-SNAPSHOT")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.4.0-SNAPSHOT")
|
||||||
|
|
|
@ -28,16 +28,22 @@ public class AppearanceManager {
|
||||||
|
|
||||||
public ActionResult reset() {
|
public ActionResult reset() {
|
||||||
final NickoProfile profile = getNickoProfile();
|
final NickoProfile profile = getNickoProfile();
|
||||||
|
final String defaultName = nameStore.getStoredName(player);
|
||||||
|
|
||||||
// Call the event.
|
// Call the event.
|
||||||
final PlayerResetDisguiseEvent event = new PlayerResetDisguiseEvent(player);
|
final PlayerResetDisguiseEvent event = new PlayerResetDisguiseEvent(player);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
profile.setName(defaultName);
|
||||||
|
profile.setSkin(defaultName);
|
||||||
|
|
||||||
|
final ActionResult result = update(true);
|
||||||
|
|
||||||
profile.setName(null);
|
profile.setName(null);
|
||||||
profile.setSkin(null);
|
profile.setSkin(null);
|
||||||
dataStore.getCache().cache(player.getUniqueId(), profile);
|
dataStore.getCache().cache(player.getUniqueId(), profile);
|
||||||
|
|
||||||
return ActionResult.error();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult update(boolean skinChange) {
|
public ActionResult update(boolean skinChange) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class FavoritesGUI {
|
||||||
final ScrollUpItem scrollUpItem = new ScrollUpItem(playerLanguage);
|
final ScrollUpItem scrollUpItem = new ScrollUpItem(playerLanguage);
|
||||||
final ScrollDownItem scrollDownItem = new ScrollDownItem(playerLanguage);
|
final ScrollDownItem scrollDownItem = new ScrollDownItem(playerLanguage);
|
||||||
|
|
||||||
final FavoriteAddItem favoriteAddItem = new FavoriteAddItem(player);
|
final FavoriteAddItem favoriteAddItem = new FavoriteAddItem(playerLanguage);
|
||||||
final FavoriteRemoveItem favoriteRemoveItem = new FavoriteRemoveItem(playerLanguage);
|
final FavoriteRemoveItem favoriteRemoveItem = new FavoriteRemoveItem(playerLanguage);
|
||||||
|
|
||||||
final NickoProfile profile = Nicko.getInstance().getDataStore().getData(player.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
final NickoProfile profile = Nicko.getInstance().getDataStore().getData(player.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
||||||
|
|
|
@ -6,34 +6,20 @@ import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.banner.Pattern;
|
import org.bukkit.block.banner.Pattern;
|
||||||
import org.bukkit.block.banner.PatternType;
|
import org.bukkit.block.banner.PatternType;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.BannerMeta;
|
import org.bukkit.inventory.meta.BannerMeta;
|
||||||
import xyz.ineanto.nicko.Nicko;
|
|
||||||
import xyz.ineanto.nicko.appearance.Appearance;
|
|
||||||
import xyz.ineanto.nicko.gui.FavoritesGUI;
|
|
||||||
import xyz.ineanto.nicko.language.LanguageKey;
|
import xyz.ineanto.nicko.language.LanguageKey;
|
||||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||||
import xyz.ineanto.nicko.profile.NickoProfile;
|
|
||||||
import xyz.ineanto.nicko.storage.PlayerDataStore;
|
|
||||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FavoriteAddItem {
|
public class FavoriteAddItem {
|
||||||
private final PlayerDataStore dataStore = Nicko.getInstance().getDataStore();
|
|
||||||
|
|
||||||
private final Player player;
|
|
||||||
private final PlayerLanguage playerLanguage;
|
private final PlayerLanguage playerLanguage;
|
||||||
private final NickoProfile profile;
|
|
||||||
|
|
||||||
public FavoriteAddItem(Player player) {
|
public FavoriteAddItem(PlayerLanguage playerLanguage) {
|
||||||
this.player = player;
|
this.playerLanguage = playerLanguage;
|
||||||
this.playerLanguage = new PlayerLanguage(player);
|
|
||||||
this.profile = dataStore.getData(player.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuppliedItem get() {
|
public SuppliedItem get() {
|
||||||
|
@ -64,17 +50,8 @@ public class FavoriteAddItem {
|
||||||
return playerLanguage.translateItem(builder, LanguageKey.GUI.Favorites.ADD);
|
return playerLanguage.translateItem(builder, LanguageKey.GUI.Favorites.ADD);
|
||||||
}, click -> {
|
}, click -> {
|
||||||
final ClickType clickType = click.getClickType();
|
final ClickType clickType = click.getClickType();
|
||||||
if (clickType.isShiftClick() && clickType.isLeftClick()) {
|
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||||
if (!profile.hasData()) {
|
click.getEvent().getView().close();
|
||||||
click.getEvent().getView().close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Appearance> favorites = profile.getFavorites();
|
|
||||||
favorites.add(profile.getAppearance());
|
|
||||||
profile.setFavorites(favorites);
|
|
||||||
dataStore.updateCache(player.getUniqueId(), profile);
|
|
||||||
new FavoritesGUI(player).open();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class RandomSkinItem {
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(playerLanguage.translateWithOops(
|
player.sendMessage(playerLanguage.translateWithOops(
|
||||||
LanguageKey.Event.Appearance.Set.ERROR,
|
LanguageKey.Event.Appearance.Set.ERROR,
|
||||||
result.getErrorKey()
|
playerLanguage.translate(result.getErrorKey(), false)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
appearanceManager.reset();
|
appearanceManager.reset();
|
||||||
|
|
|
@ -110,9 +110,6 @@ public class MojangAPI {
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
|
|
||||||
switch (con.getResponseCode()) {
|
switch (con.getResponseCode()) {
|
||||||
case 403:
|
|
||||||
logger.warning("Failed to parse request: forbidden?");
|
|
||||||
return getErrorObject();
|
|
||||||
case 404:
|
case 404:
|
||||||
case 400:
|
case 400:
|
||||||
logger.warning("Failed to parse request: Invalid Name");
|
logger.warning("Failed to parse request: Invalid Name");
|
||||||
|
|
|
@ -42,10 +42,6 @@ public class NickoProfile implements Cloneable {
|
||||||
return dataStore.getData(uuid);
|
return dataStore.getData(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Appearance getAppearance() {
|
|
||||||
return appearance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasData() {
|
public boolean hasData() {
|
||||||
return appearance.name() != null || appearance.skin() != null;
|
return appearance.name() != null || appearance.skin() != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ gui:
|
||||||
name: "Add a favorite"
|
name: "Add a favorite"
|
||||||
lore:
|
lore:
|
||||||
- "<grey>Add a new favorite appearance to the list.</grey>"
|
- "<grey>Add a new favorite appearance to the list.</grey>"
|
||||||
- "<grey>Hold <gold>SHIFT</gold> to add your current disguise!</grey>"
|
- "<grey>Hold <b><gold>SHIFT</gold></b> to add your current disguise!</grey>"
|
||||||
remove:
|
remove:
|
||||||
name: "Toggle deletion mode"
|
name: "Toggle deletion mode"
|
||||||
lore:
|
lore:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue