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
8 geänderte Dateien mit 762 neuen und 561 gelöschten Zeilen
Nur Änderungen aus Commit df2db0d63d werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -26,6 +26,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.regions.Region;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -90,7 +91,7 @@ class CheckSchemType_12 {
private CheckSchemType_12(){}
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
static AutoCheckResult autoCheck(SchematicNode schematic, ICheckSchemType type) {
AutoCheckResult result = new AutoCheckResult(type);
Clipboard clipboard;
try {

Datei anzeigen

@ -26,6 +26,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -91,7 +92,7 @@ class CheckSchemType_15 {
private CheckSchemType_15(){}
static AutoCheckResult autoCheck(Schematic schematic, ICheckSchemType type) {
static AutoCheckResult autoCheck(SchematicNode schematic, ICheckSchemType type) {
AutoCheckResult result = new AutoCheckResult(type);
Clipboard clipboard;
try {

Datei anzeigen

@ -82,15 +82,5 @@
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.schematicsystem;
import de.steamwar.core.VersionedCallable;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import org.bukkit.configuration.ConfigurationSection;
@ -74,7 +75,7 @@ public class CheckSchemType implements ICheckSchemType {
return types.get(type);
}
public AutoCheckResult autoCheck(Schematic schematic) {
public AutoCheckResult autoCheck(SchematicNode schematic) {
return VersionedCallable.call(new VersionedCallable<>(AutoCheckResult::new, 8),
new VersionedCallable<>(() -> CheckSchemType_12.autoCheck(schematic, this), 12),
new VersionedCallable<>(AutoCheckResult::new, 13),

Datei anzeigen

@ -29,14 +29,18 @@ import java.util.logging.Level;
public class SchematicSystem extends JavaPlugin {
public static final String PREFIX = "§eSchematic§8» §7";
public static SchematicSystem INSTANCE;
public static SchematicCommand SCHEMATIC_COMMAND;
@Override
public void onEnable() {
INSTANCE = this;
if (!new File(getDataFolder(), "config.yml").exists()) {
saveDefaultConfig();
Bukkit.getLogger().log(Level.SEVERE, "config.yml erstellt und geladen!");
}
CheckSchemType.init(getConfig());
getCommand("schem").setExecutor(new SchematicCommand());
SCHEMATIC_COMMAND = new SchematicCommand();
}
}

Datei anzeigen

@ -32,10 +32,109 @@ import org.bukkit.event.inventory.ClickType;
import java.util.*;
class GUI {
private GUI(){}
public class GUI {
static void changeType(Player p, Schematic schem){
public static void open(Player player) {
list(player, SchematicNode.getSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId(), null), false, "/");
}
private static void list(Player player, List<SchematicNode> schems, boolean publics, String path) {
List<SWListInv.SWListEntry<SchematicNode>> schemList = new ArrayList<>();
for(SchematicNode schem : schems) {
Material m;
if (schem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM");
else
m = SWItem.getMaterial(schem.getItem());
SWItem item = new SWItem(m, "§e" + schem.getName(), Collections.singletonList(schem.isDir()?"§9Ordner":"§7" + schem.getSchemtype().name()), schem.isDir()?false:!schem.getSchemtype().writeable(), click -> {});
if(!schem.isDir()) {
if(schem.getRank() > 0)
item.setLore(Lists.newArrayList("§7" + schem.getSchemtype().name(), "§8Rang " + schem.getRank()));
}
schemList.add(new SWListInv.SWListEntry<>(item, schem));
}
SWListInv<SchematicNode> inv = new SWListInv<>(player, "§eSchematicliste §8- §r" + path, false, schemList, (clickType, schem) -> info(player, schem));
if(publics)
inv.setItem(48, Material.BUCKET, "§7Eigene Schematics", clickType -> open(player));
else
inv.setItem(48, Material.GLASS, "§7Public Schematics", clickType -> list(player, SchematicNode.getSchematicsAccessibleByUser(0, null), true, "/"));
inv.setItem(50, Material.NAME_TAG, "§7Suche", clickType -> search(player, publics));
inv.open();
}
private static void info(Player player, SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(node.isDir()) {
list(player, SchematicNode.getSchematicNodeInNode(node), node.getOwner() == 0, node.generateBreadcrumbs(user));
} else {
SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user));
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
player.closeInventory();
SchematicSystem.SCHEMATIC_COMMAND.loadSchem(player, node);
});
if(node.getOwner() == user.getId()){
if(node.getSchemtype().writeable()){
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
ListIterator<CheckedSchematic> i = checkedSchematics.listIterator(checkedSchematics.size());
while(i.hasPrevious()) {
CheckedSchematic checkedSchematic = i.previous();
if(checkedSchematic.getNode() == node.getId()) {
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + node.getSchemtype().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
break;
}
}
}
Material mat = SWItem.getMaterial("CAULDRON_ITEM");
if(node.getItem() != null && !node.getItem().equals(""))
mat = SWItem.getMaterial(node.getItem());
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
player.closeInventory();
changeItem(player, node);
});
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
player.closeInventory();
changeType(player, node);
});
inv.setItem(5, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), "§eDownload", click -> {
player.closeInventory();
SchematicSystem.SCHEMATIC_COMMAND.download(player, node);
});
SWItem skull = SWItem.getPlayerSkull("MHF_STEVE");
skull.setCallback(click -> {
player.closeInventory();
delmembers(player, node);
});
skull.setName("§eMitglieder");
inv.setItem(6, skull);
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
player.closeInventory();
delete(player, node);
});
}else{
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), click -> {});
SteamwarUser owneruser = SteamwarUser.get(node.getOwner());
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
skull.setName("§7von §e" + owneruser.getUserName());
inv.setItem(6, skull);
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> {
player.closeInventory();
delete(player, node);
});
}
inv.setCallback(-999, click -> player.closeInventory());
inv.open();
}
}
static void changeType(Player p, SchematicNode schem){
List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
for(SchematicType type : SchematicType.values()){
if(!type.isAssignable())
@ -49,24 +148,24 @@ class GUI {
}
SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
SchematicCommand.changetype(p, schem, schematicType);
p.closeInventory();
SchematicSystem.SCHEMATIC_COMMAND.changeType(p, schem, schematicType);
});
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}
private static void deleteOwn(Player p, Schematic schem){
SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " löschen");
private static void deleteOwn(Player p, SchematicNode schem){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " löschen");
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
schem.remove();
schem.delete();
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(schem);
for(CheckedSchematic checkedSchematic : checkedSchematics) {
if(checkedSchematic.getSchemOwner() == schem.getSchemOwner() &&
checkedSchematic.getSchemName().equals(schem.getSchemName()))
checkedSchematic.remove();
checkedSchematic.remove();
}
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.getSchemName() + " §7gelöscht");
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.generateBreadcrumbs(user) + " §7gelöscht");
p.closeInventory();
});
inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory());
@ -74,13 +173,14 @@ class GUI {
inv.open();
}
private static void deleteMembership(Player p, Schematic schem){
SWInventory inv = new SWInventory(p, 9, schem.getSchemName() + " entfernen");
private static void deleteMembership(Player p, SchematicNode schem){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
SWInventory inv = new SWInventory(p, 9, schem.generateBreadcrumbs(user) + " entfernen");
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eZugriff entfernen", click -> {
SchematicMember member = SchematicMember.getSchemMemberFromDB(schem.getSchemName(), schem.getSchemOwner(), SteamwarUser.get(p.getUniqueId()).getId());
NodeMember member = NodeMember.getNodeMember(schem.getId(), user.getId());
if(member != null)
member.remove();
p.sendMessage(SchematicSystem.PREFIX + "Zugriff zu Schematic §e" + schem.getSchemName() + " §7entfernt");
member.delete();
p.sendMessage(SchematicSystem.PREFIX + "Zugriff zu Schematic §e" + schem.generateBreadcrumbs(user) + " §7entfernt");
p.closeInventory();
});
inv.setItem(8, SWItem.getDye(14), (byte) 14, "§cAbbruch", click -> p.closeInventory());
@ -88,22 +188,22 @@ class GUI {
inv.open();
}
static void delete(Player p, Schematic schem){
if(SteamwarUser.get(p.getUniqueId()).getId() == schem.getSchemOwner())
static void delete(Player p, SchematicNode schem){
if(SteamwarUser.get(p.getUniqueId()).getId() == schem.getOwner())
deleteOwn(p, schem);
else
deleteMembership(p, schem);
}
static void delmembers(Player p, Schematic schem){
List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
static void delmembers(Player p, SchematicNode schem){
List<SWListInv.SWListEntry<NodeMember>> members = new LinkedList<>();
for(NodeMember member : schem.getMembers()){
SteamwarUser user = SteamwarUser.get(member.getMember());
members.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(user.getUserName()), member));
}
SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
member.remove();
SWListInv<NodeMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
member.delete();
p.closeInventory();
delmembers(p, schem);
});
@ -111,7 +211,7 @@ class GUI {
inv.open();
}
private static void changeItem(Player p, Schematic schem){
private static void changeItem(Player p, SchematicNode schem){
List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
for(Material material : Material.values()){
SWItem item = new SWItem(material, "§7" + material.name());
@ -128,108 +228,12 @@ class GUI {
inv.open();
}
private static void info(Player p, Schematic schem){
SWInventory inv = new SWInventory(p, 9, schem.getSchemName());
if(schem.availible())
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
SchematicCommand.load(p, schem);
p.closeInventory();
});
if(schem.getSchemOwner() == SteamwarUser.get(p.getUniqueId()).getId()){
if(schem.getSchemType().writeable()){
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(p.getUniqueId());
ListIterator<CheckedSchematic> i = checkedSchematics.listIterator(checkedSchematics.size());
while(i.hasPrevious()) {
CheckedSchematic checkedSchematic = i.previous();
if(checkedSchematic.getSchemName().equals(schem.getSchemName()) &&
checkedSchematic.getSchemOwner() == schem.getSchemOwner()) {
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + schem.getSchemType().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
break;
}
}
}
Material mat = SWItem.getMaterial("CAULDRON_ITEM");
if(schem.getItem() != null && !schem.getItem().equals(""))
mat = SWItem.getMaterial(schem.getItem());
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
p.closeInventory();
changeItem(p, schem);
});
if(schem.availible())
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
p.closeInventory();
changeType(p, schem);
});
inv.setItem(5, SWItem.getMaterial("MAGENTA_GLAZED_TERRACOTTA"), "§eDownload", click -> {
p.closeInventory();
SchematicCommand.download(p, schem);
});
SWItem skull = SWItem.getPlayerSkull("MHF_STEVE");
skull.setCallback(click -> {
p.closeInventory();
delmembers(p, schem);
});
skull.setName("§eMitglieder");
inv.setItem(6, skull);
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
p.closeInventory();
delete(p, schem);
});
}else{
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {});
SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner());
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
skull.setName("§7von §e" + owneruser.getUserName());
inv.setItem(6, skull);
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> {
p.closeInventory();
delete(p, schem);
});
}
inv.setCallback(-999, click -> p.closeInventory());
inv.open();
}
static void list(Player p){
list(p, Schematic.getSchemsAccessibleByUser(SteamwarUser.get(p.getUniqueId()).getId()), false);
}
private static void list(Player p, List<Schematic> schems, boolean publics){
List<SWListInv.SWListEntry<Schematic>> schemList = new ArrayList<>();
for(Schematic schem : schems) {
Material m;
if (schem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM");
else
m = SWItem.getMaterial(schem.getItem());
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {});
if(schem.getRank() > 0)
item.setLore(Lists.newArrayList("§7" + schem.getSchemType().name(), "§8Rang " + schem.getRank()));
schemList.add(new SWListInv.SWListEntry<>(item, schem));
}
SWListInv<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", false, schemList, (clickType, schem) -> info(p, schem));
if(publics)
inv.setItem(48, Material.BUCKET, "§7Eigene Schematics", clickType -> list(p));
else
inv.setItem(48, Material.GLASS, "§7Public Schematics", clickType -> list(p, Schematic.getSchemsAccessibleByUser(0), true));
inv.setItem(50, Material.NAME_TAG, "§7Suche", clickType -> search(p, schems));
inv.open();
}
static void search(Player p, List<Schematic> schems){
SWAnvilInv inv = new SWAnvilInv(p, "§7Schematicsuche");
inv.setCallback(term -> {
ArrayList<Schematic> schemCopy = new ArrayList<>(schems);
schemCopy.removeIf(schem -> !schem.getSchemName().toLowerCase().contains(term.toLowerCase()));
list(p, schemCopy, false);
private static void search(Player player, boolean publics) {
SWAnvilInv inv = new SWAnvilInv(player, "Schematics suchen");
inv.setItem(SWItem.getMaterial("CAULDRON_ITEM"));
inv.setCallback(s -> {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
list(player, SchematicNode.filterSchems(publics?0:user.getId(), node -> node.getName().contains(s)), publics, "/");
});
inv.open();
}

Datei anzeigen

@ -1,14 +1,15 @@
name: SchematicSystem
version: "1.0"
authors: [Yaruma3341, Lixfel]
version: "2.0"
authors: [Yaruma3341, Lixfel, Chaoscaot]
depend: [SpigotCore, WorldEdit]
main: de.steamwar.schematicsystem.SchematicSystem
website: steamwar.de
api-version: "1.13"
commands:
schem:
aliases:
- schematic
- /schematic
- /schem
#schem:
# aliases:
# - schematic
# - /schematic
# - /schem
check: