13
0

Schemnodes Schematic System #93

Zusammengeführt
Lixfel hat 30 Commits von nodes nach master 2021-12-27 16:30:26 +01:00 zusammengeführt
5 geänderte Dateien mit 103 neuen und 27 gelöschten Zeilen
Nur Änderungen aus Commit 8fe2a4f648 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -47,12 +47,12 @@ public class GUI {
private static void list(Player player) { private static void list(Player player) {
SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematic(), new SchematicSelectorInjectableAdapter() { SchematicSelector selector = new SchematicSelector(player, SchematicSelector.selectSchematic(), new SchematicSelectorInjectableAdapter() {
@Override @Override
public void onListRender(SWListInv<SchematicNode> inv, SchematicNode parent) { public void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent) {
if(parent == null) { if(parent == null) {
inv.setItem(49, Material.AIR, "", clickType -> {}); inv.setItem(49, Material.AIR, "", clickType -> {});
} else { } else {
inv.setItem(49, Material.ANVIL, "§7Ordner Eigenschaften", clickType -> { inv.setItem(49, Material.ANVIL, "§7Ordner Eigenschaften", clickType -> {
info(player, parent); info(selector.getPlayer(), parent);
}); });
} }
} }

Datei anzeigen

@ -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; package de.steamwar.schematicsystem.util;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -17,10 +36,15 @@ import java.util.function.Consumer;
public class SchematicSelector { public class SchematicSelector {
@Getter
private final Player player; private final Player player;
@Getter
private final SteamwarUser user; private final SteamwarUser user;
@Getter
private final Consumer<SchematicNode> callback; private final Consumer<SchematicNode> callback;
@Getter
private final SelectorTarget target; private final SelectorTarget target;
@Getter
private final SelectorFilter filter = new SelectorFilter(); private final SelectorFilter filter = new SelectorFilter();
private SchematicSelectorInjectable injectable; private SchematicSelectorInjectable injectable;
private boolean useHooks; private boolean useHooks;
@ -28,6 +52,7 @@ public class SchematicSelector {
@Getter @Getter
private boolean allowPublics = true; private boolean allowPublics = true;
@Setter @Setter
@Getter
private String title = "{0} auswahl"; private String title = "{0} auswahl";
public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) { public SchematicSelector(Player player, SelectorTarget target, Consumer<SchematicNode> callback) {
@ -45,7 +70,7 @@ public class SchematicSelector {
public void open() { public void open() {
if(useHooks) { if(useHooks) {
injectable.onSelectorCreate(player); injectable.onSelectorCreate(this);
} }
openList(null, false); openList(null, false);
} }
@ -63,7 +88,7 @@ public class SchematicSelector {
nodes.addAll(SchematicNode.getAllSchematicsAccessibleByUser(publics?0:user.getId())); nodes.addAll(SchematicNode.getAllSchematicsAccessibleByUser(publics?0:user.getId()));
nodes.removeIf(node -> { nodes.removeIf(node -> {
if(useHooks) { if(useHooks) {
injectable.onNodeFilter(node); injectable.onNodeFilter(this, node);
} }
return !filter.matches(node); return !filter.matches(node);
}); });
@ -147,7 +172,7 @@ public class SchematicSelector {
inv.setItem(51, Material.NAME_TAG, "§7Filter", clickType -> openFilter(publics)); inv.setItem(51, Material.NAME_TAG, "§7Filter", clickType -> openFilter(publics));
if(useHooks) { if(useHooks) {
injectable.onListRender(inv, parent); injectable.onListRender(this, inv, parent);
} }
inv.open(); inv.open();
} }
@ -157,7 +182,7 @@ public class SchematicSelector {
inv.setItem(Material.CHEST); inv.setItem(Material.CHEST);
inv.setCallback(s -> { inv.setCallback(s -> {
if(useHooks) { if(useHooks) {
if(injectable.onFolderCreate(s)) { if(injectable.onFolderCreate(this, s)) {
SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId()); SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId());
openList(parent, false); openList(parent, false);
} }
@ -265,13 +290,13 @@ public class SchematicSelector {
inv.setItem(8, SWItem.getDye(10), "§eSuchen...", clickType -> { inv.setItem(8, SWItem.getDye(10), "§eSuchen...", clickType -> {
filter.setFilter(true); filter.setFilter(true);
if(useHooks) { if(useHooks) {
injectable.onFilterApply(filter); injectable.onFilterApply(this);
} }
openList(null, publics); openList(null, publics);
}); });
if(useHooks) { if(useHooks) {
injectable.onFilterRender(inv); injectable.onFilterRender(this, inv);
} }
inv.open(); inv.open();

Datei anzeigen

@ -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; package de.steamwar.schematicsystem.util;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import org.bukkit.entity.Player;
public interface SchematicSelectorInjectable { 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);
} }

Datei anzeigen

@ -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; package de.steamwar.schematicsystem.util;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
@ -6,28 +25,23 @@ import de.steamwar.sql.SchematicNode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class SchematicSelectorInjectableAdapter implements SchematicSelectorInjectable { public abstract class SchematicSelectorInjectableAdapter implements SchematicSelectorInjectable {
@Override
private Player player; public void onSelectorCreate(SchematicSelector selector) {}
@Override @Override
public void onSelectorCreate(Player player) { public void onListRender(SchematicSelector selector, SWListInv<SchematicNode> inv, SchematicNode parent) {}
this.player = player;
}
@Override @Override
public void onListRender(SWListInv<SchematicNode> inv, SchematicNode parent) {} public void onFilterRender(SchematicSelector selector, SWInventory inventory) {}
@Override @Override
public void onFilterRender(SWInventory inventory) {} public void onFilterApply(SchematicSelector selector) {}
@Override @Override
public void onFilterApply(SchematicSelector.SelectorFilter filter) {} public boolean onFolderCreate(SchematicSelector selector, String name) {
@Override
public boolean onFolderCreate(String name) {
return true; return true;
} }
@Override @Override
public void onNodeFilter(SchematicNode node) {} public void onNodeFilter(SchematicSelector selector, SchematicNode node) {}
} }

Datei anzeigen

@ -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; package de.steamwar.schematicsystem.util;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;