Ursprung
5e752943fd
Commit
683e9d57fa
@ -19,15 +19,18 @@
|
|||||||
|
|
||||||
package de.steamwar.schematicsystem.commands;
|
package de.steamwar.schematicsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.inventory.*;
|
import de.steamwar.inventory.*;
|
||||||
import de.steamwar.schematicsystem.SafeSchematicNode;
|
import de.steamwar.schematicsystem.SafeSchematicNode;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*;
|
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*;
|
||||||
|
|
||||||
@ -51,12 +54,30 @@ public class GUI {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnvilInvCloseAction onAnvilInvCloseAction(SchematicSelector selector) {
|
||||||
|
return AnvilInvCloseAction.REOPEN;
|
||||||
|
}
|
||||||
}, node -> {});
|
}, node -> {});
|
||||||
selector.setCallback(node -> info(player, node, selector));
|
selector.setCallback(node -> info(player, node, selector));
|
||||||
selector.setSingleDirOpen(false);
|
selector.setSingleDirOpen(false);
|
||||||
selector.open();
|
selector.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setCloseLeftCallback(SWAnvilInv inv, Runnable action) {
|
||||||
|
AtomicBoolean left = new AtomicBoolean(false);
|
||||||
|
inv.addCloseCallback(() -> {
|
||||||
|
if(!left.get()) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(SchematicSystem.getInstance(), action, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
inv.addLeftCallback(() -> {
|
||||||
|
left.set(true);
|
||||||
|
action.run();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private static void info(Player player, SchematicNode node, SchematicSelector back) {
|
private static void info(Player player, SchematicNode node, SchematicSelector back) {
|
||||||
SteamwarUser user = getUser(player);
|
SteamwarUser user = getUser(player);
|
||||||
SWInventory inv = new SWInventory(player, 9 * 2, node.generateBreadcrumbs(user));
|
SWInventory inv = new SWInventory(player, 9 * 2, node.generateBreadcrumbs(user));
|
||||||
@ -134,7 +155,7 @@ public class GUI {
|
|||||||
});
|
});
|
||||||
inv.setItem(16, Material.NAME_TAG, SchematicSystem.MESSAGE.parse("GUI_INFO_RENAME", player), clickType -> {
|
inv.setItem(16, Material.NAME_TAG, SchematicSystem.MESSAGE.parse("GUI_INFO_RENAME", player), clickType -> {
|
||||||
SWAnvilInv anvilInv = new SWAnvilInv(player, SchematicSystem.MESSAGE.parse("GUI_INFO_RENAME_TITLE", player, node.getName()), node.getName());
|
SWAnvilInv anvilInv = new SWAnvilInv(player, SchematicSystem.MESSAGE.parse("GUI_INFO_RENAME_TITLE", player, node.getName()), node.getName());
|
||||||
anvilInv.setItem(mat);
|
anvilInv.setItem(mat, Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_CLICK_BACK", player)), false);
|
||||||
anvilInv.setCallback(s -> {
|
anvilInv.setCallback(s -> {
|
||||||
SafeSchematicNode.Result result = SafeSchematicNode.setName(user, node, s);
|
SafeSchematicNode.Result result = SafeSchematicNode.setName(user, node, s);
|
||||||
if(result.isSuccessful()) {
|
if(result.isSuccessful()) {
|
||||||
@ -143,6 +164,7 @@ public class GUI {
|
|||||||
result.sendError(player);
|
result.sendError(player);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
setCloseLeftCallback(anvilInv, () -> info(player, node, back));
|
||||||
anvilInv.open();
|
anvilInv.open();
|
||||||
});
|
});
|
||||||
inv.setItem(17, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("GUI_INFO_DELETE", player), click -> {
|
inv.setItem(17, SWItem.getDye(1), (byte) 1, SchematicSystem.MESSAGE.parse("GUI_INFO_DELETE", player), click -> {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren