mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-10 02:19:30 +01:00
Allow default blueprint bundle to have a friendly name change in the GUI
https://github.com/BentoBoxWorld/BentoBox/issues/1543
This commit is contained in:
parent
6b852e0368
commit
a07676ac05
@ -88,26 +88,26 @@ public class AdminBlueprintCommand extends ConfirmableCommand {
|
|||||||
|
|
||||||
// Drawing x-axes
|
// Drawing x-axes
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; x++) {
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x, minY, minZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x + 0.5, minY + 0.5, minZ + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x, maxY, minZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x + 0.5, maxY + 0.5, minZ + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x, minY, maxZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x + 0.5, minY + 0.5, maxZ + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x, maxY, maxZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, x + 0.5, maxY + 0.5, maxZ + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawing y-axes
|
// Drawing y-axes
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; y++) {
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX, y, minZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX + 0.5, y + 0.5, minZ + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX, y, minZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX + 0.5, y + 0.5, minZ + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX, y, maxZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX + 0.5, y + 0.5, maxZ + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX, y, maxZ);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX + 0.5, y + 0.5, maxZ + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawing z-axes
|
// Drawing z-axes
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX, minY, z);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX + 0.5, minY + 0.5, z + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX, minY, z);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX + 0.5, minY + 0.5, z + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX, maxY, z);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, minX + 0.5, maxY + 0.5, z + 0.5);
|
||||||
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX, maxY, z);
|
user.spawnParticle(PARTICLE, PARTICLE_DUST_OPTIONS, maxX + 0.5, maxY + 0.5, z + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawing origin
|
// Drawing origin
|
||||||
|
@ -12,6 +12,7 @@ import world.bentobox.bentobox.api.addons.GameModeAddon;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.blueprints.Blueprint;
|
import world.bentobox.bentobox.blueprints.Blueprint;
|
||||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
||||||
|
import world.bentobox.bentobox.managers.BlueprintsManager;
|
||||||
|
|
||||||
public class NamePrompt extends StringPrompt {
|
public class NamePrompt extends StringPrompt {
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ public class NamePrompt extends StringPrompt {
|
|||||||
context.getForWhom().sendRawMessage("Too long");
|
context.getForWhom().sendRawMessage("Too long");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
if (!bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)) {
|
||||||
// Make a uniqueid
|
// Make a uniqueid
|
||||||
StringBuilder uniqueId = new StringBuilder(ChatColor.stripColor(input).toLowerCase(Locale.ENGLISH).replace(" ", "_"));
|
StringBuilder uniqueId = new StringBuilder(ChatColor.stripColor(input).toLowerCase(Locale.ENGLISH).replace(" ", "_"));
|
||||||
// Check if this name is unique
|
// Check if this name is unique
|
||||||
@ -57,6 +59,10 @@ public class NamePrompt extends StringPrompt {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
context.setSessionData("uniqueId", uniqueId.toString());
|
context.setSessionData("uniqueId", uniqueId.toString());
|
||||||
|
} else {
|
||||||
|
// Default stays as default
|
||||||
|
context.setSessionData("uniqueId", bb.getUniqueId());
|
||||||
|
}
|
||||||
context.setSessionData("name", input);
|
context.setSessionData("name", input);
|
||||||
return new NameSuccessPrompt(addon, bb, bp);
|
return new NameSuccessPrompt(addon, bb, bp);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,12 @@ public class BlueprintManagementPanel {
|
|||||||
private final User user;
|
private final User user;
|
||||||
private final GameModeAddon addon;
|
private final GameModeAddon addon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to display the Blueprint Management Panel
|
||||||
|
* @param plugin - BentoBox
|
||||||
|
* @param user - user to see the panel
|
||||||
|
* @param addon - game mode addon requesting the panel
|
||||||
|
*/
|
||||||
public BlueprintManagementPanel(@NonNull BentoBox plugin, @NonNull User user, @NonNull GameModeAddon addon) {
|
public BlueprintManagementPanel(@NonNull BentoBox plugin, @NonNull User user, @NonNull GameModeAddon addon) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@ -100,13 +106,12 @@ public class BlueprintManagementPanel {
|
|||||||
// Make item
|
// Make item
|
||||||
PanelItem item = new PanelItemBuilder()
|
PanelItem item = new PanelItemBuilder()
|
||||||
.name(bb.getDisplayName())
|
.name(bb.getDisplayName())
|
||||||
.description(t("edit"),
|
.description(t("edit"), t("rename"))
|
||||||
!bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME) ? t("rename") : "")
|
|
||||||
.icon(bb.getIcon())
|
.icon(bb.getIcon())
|
||||||
.clickHandler((panel, u, clickType, slot) -> {
|
.clickHandler((panel, u, clickType, slot) -> {
|
||||||
|
|
||||||
u.closeInventory();
|
u.closeInventory();
|
||||||
if (clickType.equals(ClickType.RIGHT) && !bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)) {
|
if (clickType.equals(ClickType.RIGHT)) {
|
||||||
// Rename
|
// Rename
|
||||||
askForName(u.getPlayer(), addon, bb);
|
askForName(u.getPlayer(), addon, bb);
|
||||||
} else {
|
} else {
|
||||||
@ -173,7 +178,12 @@ public class BlueprintManagementPanel {
|
|||||||
}
|
}
|
||||||
blueprints.entrySet().stream().limit(18).forEach(b -> pb.item(getBlueprintItem(addon, b.getKey(), bb, b.getValue())));
|
blueprints.entrySet().stream().limit(18).forEach(b -> pb.item(getBlueprintItem(addon, b.getKey(), bb, b.getValue())));
|
||||||
// Buttons for non-default bundle
|
// Buttons for non-default bundle
|
||||||
if (!bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)) {
|
if (bb.getUniqueId().equals(BlueprintsManager.DEFAULT_BUNDLE_NAME)) {
|
||||||
|
// Panel has a No Trash icon. If right clicked it is discarded
|
||||||
|
pb.item(36, getNoTrashIcon(addon, bb));
|
||||||
|
// Toggle permission - default is always allowed
|
||||||
|
pb.item(39, getNoPermissionIcon(addon, bb));
|
||||||
|
} else {
|
||||||
// Panel has a Trash icon. If right clicked it is discarded
|
// Panel has a Trash icon. If right clicked it is discarded
|
||||||
pb.item(36, getTrashIcon(addon, bb));
|
pb.item(36, getTrashIcon(addon, bb));
|
||||||
// Toggle permission - default is always allowed
|
// Toggle permission - default is always allowed
|
||||||
@ -273,6 +283,15 @@ public class BlueprintManagementPanel {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PanelItem getNoTrashIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
||||||
|
return new PanelItemBuilder()
|
||||||
|
.name(t("no-trash"))
|
||||||
|
.description(t("no-trash-instructions"))
|
||||||
|
.icon(Material.TNT)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private PanelItem getPermissionIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
private PanelItem getPermissionIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
||||||
return new PanelItemBuilder().icon(Material.PAINTING).name(t("permission"))
|
return new PanelItemBuilder().icon(Material.PAINTING).name(t("permission"))
|
||||||
.description(bb.isRequirePermission() ? t("perm-required") : t("perm-not-required"))
|
.description(bb.isRequirePermission() ? t("perm-required") : t("perm-not-required"))
|
||||||
@ -288,6 +307,12 @@ public class BlueprintManagementPanel {
|
|||||||
}).build();
|
}).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PanelItem getNoPermissionIcon(@NonNull GameModeAddon addon, BlueprintBundle bb) {
|
||||||
|
return new PanelItemBuilder().icon(Material.PAINTING).name(t("no-permission"))
|
||||||
|
.description(t("no-perm-required"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a panel item that fully represents a blueprint in a bundle for an addon
|
* Gets a panel item that fully represents a blueprint in a bundle for an addon
|
||||||
* @param addon - the GameMode Addon
|
* @param addon - the GameMode Addon
|
||||||
|
@ -321,9 +321,13 @@ commands:
|
|||||||
Place blueprint
|
Place blueprint
|
||||||
to right to set
|
to right to set
|
||||||
trash: "Trash"
|
trash: "Trash"
|
||||||
|
no-trash: "Cannot Trash"
|
||||||
trash-instructions: "Right click here to delete"
|
trash-instructions: "Right click here to delete"
|
||||||
|
no-trash-instructions: "Cannot trash default bundle"
|
||||||
permission: "Permission"
|
permission: "Permission"
|
||||||
|
no-permission: "No Permission"
|
||||||
perm-required: "Required"
|
perm-required: "Required"
|
||||||
|
no-perm-required: "Cannot set perm for default bundle"
|
||||||
perm-not-required: "Not Required"
|
perm-not-required: "Not Required"
|
||||||
perm-format: "&e "
|
perm-format: "&e "
|
||||||
remove: "Right click to remove"
|
remove: "Right click to remove"
|
||||||
|
Loading…
Reference in New Issue
Block a user