Skip to content

Commit

Permalink
Replaced clipboard transform items with a menu
Browse files Browse the repository at this point in the history
  • Loading branch information
SIsilicon committed Apr 15, 2024
1 parent 51ad268 commit ebd9d02
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 94 deletions.
16 changes: 0 additions & 16 deletions BP/items/buttons/flip.item.json

This file was deleted.

16 changes: 0 additions & 16 deletions BP/items/buttons/rotate_ccw.item.json

This file was deleted.

16 changes: 0 additions & 16 deletions BP/items/buttons/rotate_cw.item.json

This file was deleted.

9 changes: 2 additions & 7 deletions src/server/commands/misc/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ registerCommand(registerInformation, function (session, builder) {
"wedit:cut_button",
"wedit:paste_button",
"wedit:undo_button",
"wedit:redo_button",
"wedit:draw_line",
"wedit:config_button",
// INVENTORY ITEMS
"wedit:flip_button",
"wedit:rotate_cw_button",
"wedit:rotate_ccw_button",
"wedit:redo_button",
"wedit:mask_picker",
"wedit:draw_line",
"wedit:selection_wall",
"wedit:selection_outline",
"wedit:spawn_glass",
];

Expand Down
45 changes: 6 additions & 39 deletions src/server/tools/button_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Tool } from "./base_tool.js";
import { Tools } from "./tool_manager.js";
import { PlayerUtil } from "@modules/player_util.js";
import { Selection } from "@modules/selection.js";
import { assertClipboard } from "@modules/assert.js";

abstract class CommandButton extends Tool {
abstract readonly command: string | string[];
Expand Down Expand Up @@ -38,6 +39,11 @@ class PasteTool extends CommandButton {
outlines = new Map<PlayerSession, Selection>();

use = function (self: CommandButton, player: Player, session: PlayerSession) {
assertClipboard(session);
if (player.isSneaking) {
Server.uiForms.show("$clipboardOptions", player);
return;
}
Server.command.callCommand(player, self.command[0], self.command.slice(1) as string[]);
};

Expand Down Expand Up @@ -81,45 +87,6 @@ class RedoTool extends CommandButton {
}
Tools.register(RedoTool, "redo", "wedit:redo_button");

class RotateCWTool extends Tool {
permission = "worldedit.region.rotate";

use = function (self: Tool, player: Player, session: PlayerSession) {
const args = ["90", "-sw"];
if (player.isSneaking) {
args.push("-o");
}
Server.command.callCommand(player, "rotate", args);
};
}
Tools.register(RotateCWTool, "rotate_cw", "wedit:rotate_cw_button");

class RotateCCWTool extends Tool {
permission = "worldedit.region.rotate";

use = function (self: Tool, player: Player, session: PlayerSession) {
const args = ["-90", "-sw"];
if (player.isSneaking) {
args.push("-o");
}
Server.command.callCommand(player, "rotate", args);
};
}
Tools.register(RotateCCWTool, "rotate_ccw", "wedit:rotate_ccw_button");

class FlipTool extends Tool {
permission = "worldedit.region.flip";

use = function (self: Tool, player: Player, session: PlayerSession) {
const args = ["-sw"];
if (player.isSneaking) {
args.push("-o");
}
Server.command.callCommand(player, "flip", args);
};
}
Tools.register(FlipTool, "flip", "wedit:flip_button");

class SpawnGlassTool extends Tool {
use = function (self: Tool, player: Player) {
Server.queueCommand("setblock ~~~ glass", player);
Expand Down
1 change: 1 addition & 0 deletions src/server/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import "./hotbar_menus.js";
import "./config_menu.js";
import "./select_region_tool.js";
import "./select_gen_tool.js";
import "./paste_tool.js";
22 changes: 22 additions & 0 deletions src/server/ui/paste_tool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Server } from "@notbeer-api";

Server.uiForms.register("$clipboardOptions", {
title: "worldedit.clipboard.options",
buttons: [
{
text: "item.wedit:flip_button",
action: (_, player) => Server.command.callCommand(player, "flip"),
icon: "textures/items/flip",
},
{
text: "item.wedit:rotate_cw_button",
action: (_, player) => Server.command.callCommand(player, "rotate", ["90"]),
icon: "textures/items/rotate_cw",
},
{
text: "item.wedit:rotate_ccw_button",
action: (_, player) => Server.command.callCommand(player, "rotate", ["-90"]),
icon: "textures/items/rotate_ccw",
},
],
});
3 changes: 3 additions & 0 deletions texts/en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ msgstr "Cylinder"
msgid "worldedit.genMode.pyramid"
msgstr "Pyramid"

msgid "worldedit.clipboard.options"
msgstr "Clipboard Options"

msgid "worldedit.stack.title"
msgstr "Select stack amount"
msgid "worldedit.move.title"
Expand Down

0 comments on commit ebd9d02

Please sign in to comment.