mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-09 18:08:27 +01:00
Unregister coded.
This commit is contained in:
parent
b43197d54f
commit
af843aeb35
@ -2,8 +2,12 @@ package world.bentobox.bentobox.api.commands.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
@ -16,6 +20,9 @@ import world.bentobox.bentobox.util.Util;
|
||||
|
||||
public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||
|
||||
private Island targetIsland;
|
||||
private @Nullable UUID targetUUID;
|
||||
|
||||
public AdminUnregisterCommand(CompositeCommand parent) {
|
||||
super(parent, "unregister");
|
||||
}
|
||||
@ -30,12 +37,12 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||
@Override
|
||||
public boolean canExecute(User user, String label, List<String> args) {
|
||||
// If args are not right, show help
|
||||
if (args.size() != 1) {
|
||||
if (args.isEmpty()) {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
// Get target
|
||||
UUID targetUUID = Util.getUUID(args.get(0));
|
||||
targetUUID = Util.getUUID(args.get(0));
|
||||
if (targetUUID == null) {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
@ -44,43 +51,61 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||
user.sendMessage("general.errors.player-has-no-island");
|
||||
return false;
|
||||
}
|
||||
// Check if the player has more than one island
|
||||
Map<String, Island> islands = getIslandsXYZ(targetUUID);
|
||||
if (islands.size() == 0) {
|
||||
user.sendMessage("general.errors.player-has-no-island");
|
||||
return false;
|
||||
} else if (args.size() == 1) {
|
||||
// They need to specify which island
|
||||
user.sendMessage("commands.admin.unregister.errors.player-has-more-than-one-island");
|
||||
user.sendMessage("commands.admin.unregister.errors.specify-island-location");
|
||||
return false;
|
||||
} else if (args.size() != 2) {
|
||||
// Check if the name given works
|
||||
user.sendMessage("commands.admin.unregister.errors.specify-island-location");
|
||||
return false;
|
||||
} else if (!islands.containsKey(args.get(1))) {
|
||||
user.sendMessage("commands.admin.unregister.errors.unknown-island-location");
|
||||
return false;
|
||||
}
|
||||
targetIsland = islands.get(args.get(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
// Get target
|
||||
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||
if (targetIsland == null || targetUUID == null) {
|
||||
return true;
|
||||
}
|
||||
// Everything's fine, we can set the island as spawn :)
|
||||
askConfirmation(user, () -> unregisterPlayer(user, args.get(0), targetUUID));
|
||||
askConfirmation(user, () -> unregisterIsland(user));
|
||||
return true;
|
||||
}
|
||||
|
||||
void unregisterPlayer(User user, String targetName, UUID targetUUID) {
|
||||
void unregisterIsland(User user) {
|
||||
// Unregister island
|
||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||
if (oldIsland == null) return;
|
||||
IslandEvent.builder()
|
||||
.island(oldIsland)
|
||||
.location(oldIsland.getCenter())
|
||||
.island(targetIsland)
|
||||
.location(targetIsland.getCenter())
|
||||
.reason(IslandEvent.Reason.UNREGISTERED)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.build();
|
||||
IslandEvent.builder()
|
||||
.island(oldIsland)
|
||||
.island(targetIsland)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||
.rankChange(RanksManager.OWNER_RANK, RanksManager.VISITOR_RANK)
|
||||
.build();
|
||||
// Remove all island members
|
||||
oldIsland.getMemberSet().forEach(m -> getIslands().removePlayer(getWorld(), m));
|
||||
targetIsland.getMemberSet().forEach(m -> getIslands().removePlayer(targetIsland, m));
|
||||
// Remove all island players that reference this island
|
||||
oldIsland.getMembers().clear();
|
||||
getIslands().save(oldIsland);
|
||||
user.sendMessage("commands.admin.unregister.unregistered-island", TextVariables.XYZ, Util.xyz(oldIsland.getCenter().toVector()),
|
||||
TextVariables.NAME, targetName);
|
||||
targetIsland.getMembers().clear();
|
||||
getIslands().save(targetIsland);
|
||||
user.sendMessage("commands.admin.unregister.unregistered-island", TextVariables.XYZ, Util.xyz(targetIsland.getCenter().toVector()),
|
||||
TextVariables.NAME, getPlayers().getName(targetUUID));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -89,8 +114,22 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||
if (args.isEmpty()) {
|
||||
// Don't show every player on the server. Require at least the first letter
|
||||
return Optional.empty();
|
||||
} else if (args.size() == 2) {
|
||||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
|
||||
return Optional.of(Util.tabLimit(options, lastArg));
|
||||
} else {
|
||||
// Find out which user
|
||||
UUID uuid = getPlayers().getUUID(args.get(1));
|
||||
if (uuid != null) {
|
||||
return Optional.of(Util.tabLimit(new ArrayList<>(getIslandsXYZ(uuid).keySet()), lastArg));
|
||||
}
|
||||
}
|
||||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
|
||||
return Optional.of(Util.tabLimit(options, lastArg));
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private Map<String, Island> getIslandsXYZ(UUID target) {
|
||||
return getIslands().getOwnedIslands(getWorld(), target).stream()
|
||||
.collect(Collectors.toMap(island -> Util.xyz(island.getCenter().toVector()), island -> island));
|
||||
}
|
||||
|
||||
}
|
@ -36,6 +36,9 @@ import world.bentobox.bentobox.util.Util;
|
||||
*/
|
||||
public class BlueprintPaster {
|
||||
|
||||
/**
|
||||
* This tracks the stages of pasting from loading the chunk, pasting blocks, attachments, entities and then finishing.
|
||||
*/
|
||||
enum PasteState {
|
||||
CHUNK_LOAD,
|
||||
CHUNK_LOADING,
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
/**
|
||||
* Represents a block to be pasted
|
||||
* @author tastybento
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@ -19,8 +20,14 @@ public class BlueprintBlock {
|
||||
|
||||
@Expose
|
||||
private String blockData;
|
||||
/**
|
||||
* Front of sign
|
||||
*/
|
||||
@Expose
|
||||
private List<String> signLines;
|
||||
/**
|
||||
* Back of sign
|
||||
*/
|
||||
@Expose
|
||||
private List<String> signLines2;
|
||||
@Expose
|
||||
@ -37,8 +44,14 @@ public class BlueprintBlock {
|
||||
*/
|
||||
@Expose
|
||||
private List<Pattern> bannerPatterns;
|
||||
/**
|
||||
* Front of sign
|
||||
*/
|
||||
@Expose
|
||||
private boolean glowingText;
|
||||
/**
|
||||
* Back of sign
|
||||
*/
|
||||
@Expose
|
||||
private boolean glowingText2;
|
||||
|
||||
|
@ -326,11 +326,10 @@ public class IslandsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the islands for this player in this world. If they are in a team,
|
||||
* the team island is returned.
|
||||
* Gets all the islands for this player in this world including team islands.
|
||||
*
|
||||
* @param world world to check
|
||||
* @param uniqueId user's uuid
|
||||
* @param uniqueId user's UUID
|
||||
* @return List of islands or empty list if none found for user
|
||||
*/
|
||||
@NonNull
|
||||
@ -338,6 +337,36 @@ public class IslandsManager {
|
||||
return islandCache.getIslands(world, uniqueId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the islands for this player in this world that this player owns.
|
||||
*
|
||||
* @param world world to check
|
||||
* @param uniqueId user's UUID
|
||||
* @return List of islands or empty list if none found for user
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@NonNull
|
||||
public Set<Island> getOwnedIslands(@NonNull World world, @NonNull User user) {
|
||||
if (user.getUniqueId() == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return getOwnedIslands(world, user.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the islands for this player in this world that this player owns.
|
||||
*
|
||||
* @param world world to check
|
||||
* @param uniqueId user's UUID
|
||||
* @return List of islands or empty list if none found for user
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@NonNull
|
||||
public Set<Island> getOwnedIslands(@NonNull World world, @NonNull UUID uniqueId) {
|
||||
return islandCache.getIslands(world, uniqueId).stream().filter(island -> uniqueId.equals(island.getOwner()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the active island for this player. If they are in a team, the team
|
||||
* island is returned. User may have more than one island. Returns the island
|
||||
|
@ -171,6 +171,7 @@ public class PlaceholdersManager {
|
||||
}
|
||||
// Counts
|
||||
// Number of online members
|
||||
// {@since 2.1.0}
|
||||
registerPlaceholder(addon, "island_online_members_count", user -> {
|
||||
if (user == null)
|
||||
return "";
|
||||
|
@ -179,7 +179,7 @@ commands:
|
||||
island-is-spawn: "&6 Ostrov je spawn. Jsi si jistý? Potvrď opětovným zadáním
|
||||
příkazu."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: <owner> [x,y,z]
|
||||
description: odregistrovat vlastníka z ostrova, ale zachovat bloky ostrova
|
||||
unregistered-island: "&a Hráč odregistrován z ostrova [xyz]."
|
||||
info:
|
||||
|
@ -188,7 +188,7 @@ commands:
|
||||
island-is-spawn: "&6 Die Insel ist der Spawn. Bist du sicher? Gib den Befehl
|
||||
zur Bestätigung noch einmal ein."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: Besitzer von Insel entfernen, aber Inselblöcke behalten
|
||||
unregistered-island: "&a Unregistrierter Spieler von der Insel bei [xyz]."
|
||||
info:
|
||||
|
@ -192,9 +192,13 @@ commands:
|
||||
for possible errors.'
|
||||
island-is-spawn: '&6 Island is spawn. Are you sure? Enter command again to confirm.'
|
||||
unregister:
|
||||
parameters: <owner>
|
||||
parameters: <owner> [x,y,z]
|
||||
description: unregister owner from island, but keep island blocks
|
||||
unregistered-island: '&a Unregistered [name] from island at [xyz].'
|
||||
errors:
|
||||
unknown-island-location: "&c Unknown island location"
|
||||
specify-island-location: "&c Specify island location in x,y,z format"
|
||||
player-has-more-than-one-island: "&c Player has more than one island"
|
||||
info:
|
||||
parameters: <player>
|
||||
description: get info on where you are or player's island
|
||||
|
@ -190,7 +190,7 @@ commands:
|
||||
island-is-spawn: "&6La isla está spawneada. ¿Estás seguro? Ingrese el comando
|
||||
nuevamente para confirmar."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: Desregistrar propietario de isla, pero mantener bloques de islas
|
||||
unregistered-island: "&aRemover jugador de la isla registrada en [xyz]."
|
||||
info:
|
||||
|
@ -185,7 +185,7 @@ commands:
|
||||
island-is-spawn: "&6 L'île est un spawn. Êtes-vous sûr? Entrez à nouveau la
|
||||
commande pour confirmer."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: désenregistrer le propriétaire de l''île, mais garder les blocs
|
||||
de l''île
|
||||
unregistered-island: "&b [name] &a a été supprimé de l'île à [xyz]."
|
||||
|
@ -182,7 +182,7 @@ commands:
|
||||
island-is-spawn: "&6 Otok je mrijest. Jesi li siguran? Ponovno unesite naredbu
|
||||
za potvrdu."
|
||||
unregister:
|
||||
parameters: "<vlasnik>"
|
||||
parameters: "<vlasnik> [x,y,z]"
|
||||
description: odjaviti vlasnika s otoka, ali zadržati otočne blokove
|
||||
unregistered-island: "&a Neregistrirano [name] otoka na [xyz]."
|
||||
info:
|
||||
|
@ -190,7 +190,7 @@ commands:
|
||||
island-is-spawn: "&6 A sziget spawn. biztos vagy ebben? A megerősítéshez írja
|
||||
be újra a parancsot."
|
||||
unregister:
|
||||
parameters: "<tulajdonos>"
|
||||
parameters: "<tulajdonos> [x,y,z]"
|
||||
description: törölje a tulajdonos regisztrációját a szigetről, de tartsa meg
|
||||
a szigettömböket
|
||||
unregistered-island: "&a Nem regisztrált [name] a következő szigetről: [xyz]."
|
||||
|
@ -190,7 +190,7 @@ commands:
|
||||
island-is-spawn: "&6 Pulau muncul. Apa kamu yakin? Masukkan perintah lagi untuk
|
||||
mengonfirmasi."
|
||||
unregister:
|
||||
parameters: "<pemilik>"
|
||||
parameters: "<pemilik> [x,y,z]"
|
||||
description: batalkan pendaftaran pemilik dari pulau, tetapi pertahankan blok
|
||||
pulau
|
||||
unregistered-island: "&a [name] tidak terdaftar dari pulau di [xyz]."
|
||||
|
@ -364,7 +364,7 @@ commands:
|
||||
title: "&d=========== Isole nel Cestino ==========="
|
||||
unregister:
|
||||
description: dissocia un proprietario dall'isola, ma mantenendo i blocchi dell'isola
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
unregistered-island: "&aDisassociato il giocatore dall'isola a [xyz]."
|
||||
version:
|
||||
description: mostra le versioni di BentoBox e degli addons
|
||||
|
@ -170,7 +170,7 @@ commands:
|
||||
cannot-make-island: "&c島はここに配置できません。申し訳ありません。考えられるエラーについては、コンソールをご覧ください。"
|
||||
island-is-spawn: "&6島が生成されます。本気ですか?もう一度コマンドを入力して確認します。"
|
||||
unregister:
|
||||
parameters: "<所有者>"
|
||||
parameters: "<所有者> [x,y,z]"
|
||||
description: 島から所有者を登録解除するが、島のブロックを維持する
|
||||
unregistered-island: "[xyz]で島から未登録のプレーヤー。"
|
||||
info:
|
||||
|
@ -164,7 +164,7 @@ commands:
|
||||
cannot-make-island: "&c 섬은 이곳에 만들수 없습니다. 죄송합니다. 콘솔을 참고해주세요."
|
||||
island-is-spawn: "&6 섬이 생성되었습니다. 정말로 하시겠습니까? 명령어를 한번더 입력해주세요."
|
||||
unregister:
|
||||
parameters: "<주인>"
|
||||
parameters: "<주인> [x,y,z]"
|
||||
description: 섬을 주인없는 섬으로 만들지만 섬은 유지됩니다
|
||||
unregistered-island: "&a [xyz]에 있는 [name]의 섬을 주인 없는 섬으로 만들었습니다."
|
||||
info:
|
||||
|
@ -385,7 +385,7 @@ commands:
|
||||
uz spēlētāja salu no atkritnes."
|
||||
unregister:
|
||||
description: atreģistrē īpašnieku no salas paturot salas blokus
|
||||
parameters: "<īpašnieks>"
|
||||
parameters: "<īpašnieks> [x,y,z]"
|
||||
unregistered-island: "&aSpēlētājs atreģistrēts no salas ar koordinātēm [xyz]."
|
||||
version:
|
||||
description: attaino BentoBox un papildinājumu versijas
|
||||
|
@ -186,7 +186,7 @@ commands:
|
||||
island-is-spawn: "&6 Eiland wordt uitgezet. Weet je het zeker? Voer de opdracht
|
||||
nogmaals in om te bevestigen."
|
||||
unregister:
|
||||
parameters: "<eigenaar>"
|
||||
parameters: "<eigenaar> [x,y,z]"
|
||||
description: de registratie van de eigenaar van het eiland ongedaan maken, maar
|
||||
eilandblokken behouden
|
||||
unregistered-island: "&a niet-geregistreerde [name] van het eiland op [xyz]."
|
||||
|
@ -174,7 +174,7 @@ commands:
|
||||
island-is-spawn: '&6 Ta wyspa jest wyspą spawnu. Jesteś pewny? Wpisz ponownie
|
||||
tę komendę.'
|
||||
unregister:
|
||||
parameters: <właściciel>
|
||||
parameters: "<właściciel> [x,y,z]"
|
||||
description: wyrejestruj właściciela z wyspy, ale zachowaj bloki wyspy
|
||||
unregistered-island: '&aWyrejestrowano gracza z wyspy [xyz].'
|
||||
info:
|
||||
|
@ -192,7 +192,7 @@ commands:
|
||||
island-is-spawn: "&6 Ilha é spawn. Você tem certeza? Digite o comando novamente
|
||||
para confirmar."
|
||||
unregister:
|
||||
parameters: "<proprietário>"
|
||||
parameters: "<proprietário> [x,y,z]"
|
||||
description: Remover o registro de dono da ilha, mas manter os blocos da ilha
|
||||
unregistered-island: "&a Registro removido de [name] de ilha em [xyz]."
|
||||
info:
|
||||
|
@ -173,7 +173,7 @@ commands:
|
||||
island-is-spawn: '&6 Essa ilha é o spawn. Você tem certeza? Digite o comando
|
||||
novamente para confirmar.'
|
||||
unregister:
|
||||
parameters: <dono>
|
||||
parameters: "<dono> [x,y,z]"
|
||||
description: desregistrar dono da ilha, mas manter os blocos
|
||||
unregistered-island: '&a [name] desregistrado da ilha em [xyz].'
|
||||
info:
|
||||
|
@ -187,7 +187,7 @@ commands:
|
||||
island-is-spawn: "&6 Insula este reprodusă. Esti sigur? Introduceți din nou
|
||||
comanda pentru a confirma."
|
||||
unregister:
|
||||
parameters: "<proprietar>"
|
||||
parameters: "<proprietar> [x,y,z]"
|
||||
description: anulați înregistrarea proprietarului de pe insulă, dar păstrați
|
||||
blocurile de insule
|
||||
unregistered-island: "&a [name] neînregistrat de pe insulă la [xyz]."
|
||||
|
@ -185,7 +185,7 @@ commands:
|
||||
island-is-spawn: "&6Остров является спавном. Вы уверены? Введите команду снова
|
||||
для подтверждения."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: разрегистрирует остров, но сохраняет блоки на острове
|
||||
unregistered-island: "&aИгрок [name] разрегистрирован с острова на координатах
|
||||
[xyz]."
|
||||
|
@ -186,7 +186,7 @@ commands:
|
||||
island-is-spawn: "&6Başlangıç adası, buna emin misiniz ?Kabul etmek için komutu
|
||||
tekrar girin!"
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: Oyuncuyu adadan siler ama ada silinmez.
|
||||
unregistered-island: "&aOyuncu başarıyla &e[xyz] &akoordinatlarındaki adadan
|
||||
silindi!"
|
||||
|
@ -185,7 +185,7 @@ commands:
|
||||
консоль для можливих помилок."
|
||||
island-is-spawn: "&6 Острів ікру. Ти впевнений? Введіть команду ще раз для підтвердження."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: скасувати реєстрацію власника з острова, але зберегти блоки острова
|
||||
unregistered-island: "&a Незареєстрований [name] з острова на [xyz]."
|
||||
info:
|
||||
|
@ -180,7 +180,7 @@ commands:
|
||||
island-is-spawn: "&6 Đảo là điểm triệu hồi. Bạn chắc chứ? Nhập lần nữa để xác
|
||||
nhận."
|
||||
unregister:
|
||||
parameters: "<chủ>"
|
||||
parameters: "<chủ> [x,y,z]"
|
||||
description: hủy đăng kí chủ đảo khỏi đảo này. nhưng giữ lại tài nguyên đảo
|
||||
unregistered-island: "&a Đã hủy đăng kí [name] khỏi đảo tại [xyz]."
|
||||
info:
|
||||
|
@ -176,7 +176,7 @@ commands:
|
||||
&c所处位置为出生点岛屿, 您确定要将玩家注册到这个岛屿上?
|
||||
&6请再次输入命令以确认。
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: 注销岛主身份, 但保留岛屿资源。
|
||||
unregistered-island: "&a已将岛主 &b[name] &a从位于 &b[xyz] &a的岛屿注销。"
|
||||
info:
|
||||
|
@ -187,7 +187,7 @@ commands:
|
||||
&c所處位置為出生點島嶼, 您確定要將玩家注冊到這個島嶼上?
|
||||
&6請再次輸入命令以確認。
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: "將島主註銷但保留方塊"
|
||||
unregistered-island: "&a已將位於 [xyz] 的島嶼的玩家註銷。"
|
||||
info:
|
||||
|
Loading…
Reference in New Issue
Block a user