feat: reset skin via admin panel
This commit is contained in:
parent
8611ef2604
commit
4eecbf416e
7 changed files with 62 additions and 17 deletions
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>xyz.ineanto</groupId>
|
||||
<artifactId>nicko</artifactId>
|
||||
<version>1.0.3-RC1</version>
|
||||
<version>1.0.4-RC1</version>
|
||||
<name>Nicko</name>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package xyz.ineanto.nicko.event;
|
||||
|
||||
import xyz.ineanto.nicko.NickoBukkit;
|
||||
import xyz.ineanto.nicko.appearance.ActionResult;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import xyz.ineanto.nicko.NickoBukkit;
|
||||
import xyz.ineanto.nicko.appearance.ActionResult;
|
||||
|
||||
public class PlayerQuitListener implements Listener {
|
||||
@EventHandler
|
||||
|
|
|
@ -29,7 +29,7 @@ public class PlayerCheckGUI {
|
|||
|
||||
final List<Item> items = Bukkit.getOnlinePlayers().stream()
|
||||
.map(Entity::getUniqueId)
|
||||
.map(uuid -> new PlayerInformationItem(i18n, uuid))
|
||||
.map(uuid -> new PlayerInformationItem(i18n, Bukkit.getPlayer(uuid)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final AdminGUI parent = new AdminGUI(player);
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package xyz.ineanto.nicko.gui.items.admin.check;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.ineanto.nicko.NickoBukkit;
|
||||
import xyz.ineanto.nicko.appearance.AppearanceManager;
|
||||
import xyz.ineanto.nicko.gui.ChoiceGUI;
|
||||
import xyz.ineanto.nicko.gui.PlayerCheckGUI;
|
||||
import xyz.ineanto.nicko.gui.items.ItemDefaults;
|
||||
import xyz.ineanto.nicko.gui.items.common.choice.ChoiceCallback;
|
||||
import xyz.ineanto.nicko.i18n.I18N;
|
||||
import xyz.ineanto.nicko.i18n.I18NDict;
|
||||
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.SkullBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.AsyncItem;
|
||||
|
@ -17,35 +22,61 @@ import xyz.xenondevs.invui.util.MojangApiUtils;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerInformationItem extends AsyncItem {
|
||||
public PlayerInformationItem(I18N i18n, UUID uuid) {
|
||||
private final Player target;
|
||||
private final NickoProfile profile;
|
||||
|
||||
public PlayerInformationItem(I18N i18n, Player target) {
|
||||
super(new SuppliedItem(() -> {
|
||||
final ItemBuilder builder = new ItemBuilder(Material.PAINTING);
|
||||
return i18n.translateItem(builder, I18NDict.GUI.LOADING);
|
||||
}, (click -> true)).getItemProvider(), () -> {
|
||||
final Player player = Bukkit.getPlayer(uuid);
|
||||
try {
|
||||
final SkullBuilder skull = new SkullBuilder(uuid);
|
||||
final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
|
||||
final Optional<NickoProfile> optionalProfile = dataStore.getData(uuid);
|
||||
final SkullBuilder skull = new SkullBuilder(target.getUniqueId());
|
||||
final Optional<NickoProfile> optionalProfile = NickoBukkit.getInstance().getDataStore().getData(target.getUniqueId());
|
||||
|
||||
if (optionalProfile.isPresent()) {
|
||||
final NickoProfile profile = optionalProfile.get();
|
||||
return i18n.translateItem(skull, I18NDict.GUI.Admin.CHECK,
|
||||
player.getName(),
|
||||
target.getName(),
|
||||
(profile.hasData() ? "§a✔" : "§c❌"),
|
||||
(profile.getName() == null ? "§7N/A" : profile.getName()),
|
||||
(profile.getSkin() == null ? "§7N/A" : profile.getSkin()));
|
||||
}
|
||||
} catch (MojangApiUtils.MojangApiException | IOException e) {
|
||||
NickoBukkit.getInstance().getLogger().severe("Unable to get head for specified UUID ( " + uuid + ")! (GUI/PlayerCheck)");
|
||||
NickoBukkit.getInstance().getLogger().severe("Unable to get head for specified UUID ( " + target.getUniqueId() + ")! (GUI/PlayerCheck)");
|
||||
}
|
||||
|
||||
return ItemDefaults.getErrorSkullItem(i18n, I18NDict.GUI.Admin.CHECK,
|
||||
"§4???", "§cN/A", "§cN/A", "§cN/A"
|
||||
"§c§l?!?", "§cN/A", "§cN/A", "§cN/A"
|
||||
);
|
||||
});
|
||||
this.target = target;
|
||||
this.profile = NickoBukkit.getInstance().getDataStore().getData(target.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClick(@NotNull ClickType click, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
if (click.isLeftClick() || click.isRightClick()) {
|
||||
if (profile.hasData()) {
|
||||
event.getView().close();
|
||||
new ChoiceGUI(player, new ChoiceCallback() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
final AppearanceManager appearanceManager = new AppearanceManager(target);
|
||||
appearanceManager.reset();
|
||||
final I18N i18n = new I18N(player);
|
||||
player.sendMessage(i18n.translate(I18NDict.Event.Admin.Check.REMOVE_SKIN, target.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
new PlayerCheckGUI(player).open();
|
||||
}
|
||||
}).open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,12 @@ public class I18NDict {
|
|||
public static final String INVALIDATE_ENTRY = CACHE_KEY + "invalidate_entry";
|
||||
|
||||
}
|
||||
|
||||
public static class Check {
|
||||
private static final String CHECK_KEY = ADMIN_KEY + "check.";
|
||||
|
||||
public static final String REMOVE_SKIN = CHECK_KEY + "remove_skin";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Settings {
|
||||
|
|
|
@ -26,6 +26,8 @@ event:
|
|||
cache:
|
||||
invalidate_cache: "§fComplete cache invalidated."
|
||||
invalidate_entry: "§6{0} §fhas been invalidated."
|
||||
check:
|
||||
remove_skin: "§fSkin removed from player."
|
||||
|
||||
gui:
|
||||
title:
|
||||
|
@ -33,7 +35,7 @@ gui:
|
|||
settings: "Nicko > Settings"
|
||||
admin: "Nicko > Administration"
|
||||
check: "Nicko > Admin... > Check"
|
||||
confirm: "... > Invalidate > Confirm"
|
||||
confirm: "... > Confirm action"
|
||||
cache: "Nicko > Admin... > Cache"
|
||||
invalidate_skin: "... > Cache > Invalidate"
|
||||
|
||||
|
@ -101,6 +103,8 @@ gui:
|
|||
- "§cNicked: §a{1}"
|
||||
- "§cName: §6{2}"
|
||||
- "§cSkin: §6{3}"
|
||||
- " "
|
||||
- "§7§oClick to remove skin!"
|
||||
cache:
|
||||
statistics:
|
||||
name: "Statistics"
|
||||
|
|
|
@ -26,6 +26,8 @@ event:
|
|||
cache:
|
||||
invalidate_cache: "§fCache complet invalidé."
|
||||
invalidate_entry: "§6{0} §fa été invalidé."
|
||||
check:
|
||||
remove_skin: "§fSkin retiré du joueur."
|
||||
|
||||
gui:
|
||||
title:
|
||||
|
@ -33,7 +35,7 @@ gui:
|
|||
settings: "Nicko > Paramètres"
|
||||
admin: "Nicko > Administration"
|
||||
check: "Nicko > Admin... > Vérification"
|
||||
confirm: "... > Invalider > Confirmer"
|
||||
confirm: "... > Confirmer l'action"
|
||||
cache: "Nicko > Admin... > Cache"
|
||||
invalidate_skin: "... > Cache > Invalider"
|
||||
|
||||
|
@ -96,6 +98,8 @@ gui:
|
|||
- "§cDéguisé: §a{1}"
|
||||
- "§cNom: §6{2}"
|
||||
- "§cSkin: §6{3}"
|
||||
- " "
|
||||
- "§7§oCliquez pour retirer le skin!"
|
||||
cache:
|
||||
statistics:
|
||||
name: "Statistiques"
|
||||
|
|
Loading…
Reference in a new issue