Schemnodes Schematic System #93
@ -47,12 +47,12 @@ public class GUI {
|
||||
private static void list(Player player) {
|
||||
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematic(), new SchematicSelectorInjectableAdapter() {
|
||||
@Override
|
||||
public void onListRender(SWListInv<SchematicNode> inv, SchematicNode parent) {
|
||||
public void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent) {
|
||||
if(parent == null) {
|
||||
inv.setItem(49, Material.AIR, "", clickType -> {});
|
||||
} else {
|
||||
inv.setItem(49, Material.ANVIL, "§7Ordner Eigenschaften", clickType -> {
|
||||
info(player, parent);
|
||||
info(selector.getPlayer(), parent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -17,10 +36,15 @@ import java.util.function.Consumer;
|
||||
|
||||
public class SchematicSelector {
|
||||
|
||||
@Getter
|
||||
private final Player player;
|
||||
@Getter
|
||||
private final SteamwarUser user;
|
||||
@Getter
|
||||
private final Consumer<SchematicNode> callback;
|
||||
@Getter
|
||||
private final SelectorTarget target;
|
||||
@Getter
|
||||
private final SelectorFilter filter = new SelectorFilter();
|
||||
private SchematicSelectorInjectable injectable;
|
||||
private boolean useHooks;
|
||||
@ -28,6 +52,7 @@ public class SchematicSelector {
|
||||
@Getter
|
||||
private boolean allowPublics = true;
|
||||
@Setter
|
||||
@Getter
|
||||
private String title = "{0} auswahl";
|
||||
|
||||
public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) {
|
||||
@ -45,7 +70,7 @@ public class SchematicSelector {
|
||||
|
||||
public void open() {
|
||||
if(useHooks) {
|
||||
injectable.onSelectorCreate(player);
|
||||
injectable.onSelectorCreate(this);
|
||||
}
|
||||
openList(null, false);
|
||||
}
|
||||
@ -63,7 +88,7 @@ public class SchematicSelector {
|
||||
nodes.addAll(SchematicNode.getAllSchematicsAccessibleByUser(publics?0:user.getId()));
|
||||
nodes.removeIf(node -> {
|
||||
if(useHooks) {
|
||||
injectable.onNodeFilter(node);
|
||||
injectable.onNodeFilter(this, node);
|
||||
}
|
||||
return !filter.matches(node);
|
||||
});
|
||||
@ -147,7 +172,7 @@ public class SchematicSelector {
|
||||
inv.setItem(51, Material.NAME_TAG, "§7Filter", clickType -> openFilter(publics));
|
||||
|
||||
if(useHooks) {
|
||||
injectable.onListRender(inv, parent);
|
||||
injectable.onListRender(this, inv, parent);
|
||||
}
|
||||
inv.open();
|
||||
}
|
||||
@ -157,7 +182,7 @@ public class SchematicSelector {
|
||||
inv.setItem(Material.CHEST);
|
||||
inv.setCallback(s -> {
|
||||
if(useHooks) {
|
||||
if(injectable.onFolderCreate(s)) {
|
||||
if(injectable.onFolderCreate(this, s)) {
|
||||
SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId());
|
||||
openList(parent, false);
|
||||
}
|
||||
@ -265,13 +290,13 @@ public class SchematicSelector {
|
||||
inv.setItem(8, SWItem.getDye(10), "§eSuchen...", clickType -> {
|
||||
filter.setFilter(true);
|
||||
if(useHooks) {
|
||||
injectable.onFilterApply(filter);
|
||||
injectable.onFilterApply(this);
|
||||
}
|
||||
openList(null, publics);
|
||||
});
|
||||
|
||||
if(useHooks) {
|
||||
injectable.onFilterRender(inv);
|
||||
injectable.onFilterRender(this, inv);
|
||||
}
|
||||
|
||||
inv.open();
|
||||
|
@ -1,21 +1,39 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.util;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface SchematicSelectorInjectable {
|
||||
|
||||
void onSelectorCreate(Player player);
|
||||
void onSelectorCreate(SchematicSelector selector);
|
||||
|
||||
void onListRender(SWListInv<SchematicNode> inv, SchematicNode parent);
|
||||
void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent);
|
||||
|
||||
void onFilterRender(SWInventory inventory);
|
||||
void onFilterRender(SchematicSelector selector, SWInventory inventory);
|
||||
|
||||
void onFilterApply(SchematicSelector.SelectorFilter filter);
|
||||
void onFilterApply(SchematicSelector selector);
|
||||
|
||||
boolean onFolderCreate(String name);
|
||||
boolean onFolderCreate(SchematicSelector selector, String name);
|
||||
|
||||
void onNodeFilter(SchematicNode node);
|
||||
void onNodeFilter(SchematicSelector selector, SchematicNode node);
|
||||
}
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.util;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
@ -6,28 +25,23 @@ import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class SchematicSelectorInjectableAdapter implements SchematicSelectorInjectable {
|
||||
|
||||
private Player player;
|
||||
@Override
|
||||
public void onSelectorCreate(SchematicSelector selector) {}
|
||||
|
||||
@Override
|
||||
public void onSelectorCreate(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
public void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent) {}
|
||||
|
||||
@Override
|
||||
public void onListRender(SWListInv<SchematicNode> inv, SchematicNode parent) {}
|
||||
public void onFilterRender(SchematicSelector selector, SWInventory inventory) {}
|
||||
|
||||
@Override
|
||||
public void onFilterRender(SWInventory inventory) {}
|
||||
public void onFilterApply(SchematicSelector selector) {}
|
||||
|
||||
@Override
|
||||
public void onFilterApply(SchematicSelector.SelectorFilter filter) {}
|
||||
|
||||
@Override
|
||||
public boolean onFolderCreate(String name) {
|
||||
public boolean onFolderCreate(SchematicSelector selector, String name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNodeFilter(SchematicNode node) {}
|
||||
public void onNodeFilter(SchematicSelector selector, SchematicNode node) {}
|
||||
}
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.schematicsystem.util;
|
||||
|
||||
import de.steamwar.inventory.SWItem;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren