mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 12:35:12 +01:00
editor finish
This commit is contained in:
parent
8429efd738
commit
6667d6ed94
@ -9,24 +9,22 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot:1.14.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sainttx.holograms:Holograms:2.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.tnemc:Reserve:0.1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.black_ixx:playerpoints:2.1.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.milkbowl:VaultAPI:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.milkbowl:vault:1.7.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-nop:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.23.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.14.4-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.1-SNAPSHOT" level="project" />
|
||||
|
19
pom.xml
19
pom.xml
@ -23,16 +23,21 @@
|
||||
<id>private</id>
|
||||
<url>https://repo.songoda.com/artifactory/private/</url>
|
||||
</repository>
|
||||
<!-- sk89q-repo and spigot-repo are required for worldguard -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
@ -57,14 +62,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1</version>
|
||||
<artifactId>vault</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.core.library.settings;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -179,10 +180,9 @@ public class Config {
|
||||
fileConfiguration.addDefault(setting.getCompleteKey(), setting.getDefaultValue());
|
||||
setting.getCategory().addSetting(setting);
|
||||
}
|
||||
fileConfiguration.options().copyDefaults(true);
|
||||
}
|
||||
|
||||
fileConfiguration.options().copyDefaults(true);
|
||||
save();
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
@ -305,11 +305,10 @@ public class Config {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
fileConfiguration.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
public FileConfiguration getFileConfiguration() {
|
||||
|
@ -23,21 +23,20 @@ public class ConfigCategoriesGUI extends AbstractGUI {
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.selection = selection;
|
||||
init("test", 54);
|
||||
init("Settings Editor", 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
createButton(0, LegacyMaterials.getMaterial("OAK_FENCE_GATE").getMaterial(), "Back");
|
||||
registerClickable(0, ((player1, inventory1, cursor, slot, type) ->
|
||||
selection.init("test", selection.getInventory().getSize())));
|
||||
selection.init("Settings Editor", selection.getInventory().getSize())));
|
||||
|
||||
for (int i = 9; i - 9 < config.getCategories().size(); i++) {
|
||||
Category category = config.getCategories().get(i - 9);
|
||||
createButton(i, Material.STONE, category.getKey());
|
||||
registerClickable(i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
new ConfigEditorGUI(plugin, player, category, null, this);
|
||||
}));
|
||||
createButton(i, LegacyMaterials.WRITABLE_BOOK.getMaterial(), "&9&l" + category.getKey());
|
||||
registerClickable(i, ((player1, inventory1, cursor, slot, type) ->
|
||||
new ConfigEditorGUI(plugin, player, category, null, this)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class ConfigEditorGUI extends AbstractGUI {
|
||||
this.narrow = narrow;
|
||||
this.narrowed = narrowed;
|
||||
this.categories = categories;
|
||||
init("test", 54);
|
||||
init("Settings Editor", 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,7 +37,7 @@ public class ConfigEditorGUI extends AbstractGUI {
|
||||
|
||||
createButton(0, LegacyMaterials.getMaterial("OAK_FENCE_GATE").getMaterial(), "Back");
|
||||
registerClickable(0, ((player1, inventory1, cursor, slot, type) ->
|
||||
categories.init("test", categories.getInventory().getSize())));
|
||||
categories.init("Settings Editor", categories.getInventory().getSize())));
|
||||
|
||||
List<String> ran = new ArrayList<>();
|
||||
int j = 9;
|
||||
@ -48,7 +48,7 @@ public class ConfigEditorGUI extends AbstractGUI {
|
||||
|
||||
if (!ran.contains(key)) {
|
||||
if (canNarrow) {
|
||||
createButton(j, Material.STONE, key);
|
||||
createButton(j, LegacyMaterials.BOOK.getMaterial(), "&9&l" + key);
|
||||
registerClickable(j, ((player1, inventory1, cursor, slot, type) ->
|
||||
new ConfigEditorGUI(plugin, player1, narrow.narrow(key), key, categories)));
|
||||
} else {
|
||||
@ -59,14 +59,14 @@ public class ConfigEditorGUI extends AbstractGUI {
|
||||
StringBuilder value = new StringBuilder("&a");
|
||||
if (config.isString(setting.getCompleteKey())) {
|
||||
value.append(setting.getString());
|
||||
material = LegacyMaterials.getMaterial("PAPER").getMaterial();
|
||||
material = LegacyMaterials.PAPER.getMaterial();
|
||||
registerClickable(j, ((player1, inventory1, cursor, slot, type) -> {
|
||||
ChatPrompt prompt = ChatPrompt.showPrompt(plugin, player, "Enter your new value.", event ->
|
||||
config.set(setting.getCompleteKey(), event.getMessage().trim()));
|
||||
prompt.setOnClose(() -> init("test", inventory.getSize()));
|
||||
prompt.setOnClose(() -> init("Settings Editor", inventory.getSize()));
|
||||
}));
|
||||
} else if (isNumber(setting)) {
|
||||
material = LegacyMaterials.getMaterial("CLOCK").getMaterial();
|
||||
material = LegacyMaterials.CLOCK.getMaterial();
|
||||
registerClickable(j, ((player1, inventory1, cursor, slot, type) -> {
|
||||
ChatPrompt prompt = ChatPrompt.showPrompt(plugin, player, "Enter your new value.", event -> {
|
||||
if (config.isInt(setting.getCompleteKey())) {
|
||||
@ -77,7 +77,7 @@ public class ConfigEditorGUI extends AbstractGUI {
|
||||
config.set(setting.getCompleteKey(), Long.parseLong(event.getMessage().trim()));
|
||||
}
|
||||
});
|
||||
prompt.setOnClose(() -> init("test", inventory.getSize()));
|
||||
prompt.setOnClose(() -> init("Settings Editor", inventory.getSize()));
|
||||
}));
|
||||
if (config.isInt(setting.getCompleteKey())) {
|
||||
value.append(setting.getInt());
|
||||
@ -88,18 +88,24 @@ public class ConfigEditorGUI extends AbstractGUI {
|
||||
}
|
||||
} else if (config.isBoolean(setting.getCompleteKey())) {
|
||||
value.append(setting.getBoolean());
|
||||
material = LegacyMaterials.getMaterial("LEVER").getMaterial();
|
||||
material = LegacyMaterials.LEVER.getMaterial();
|
||||
registerClickable(j, ((player1, inventory1, cursor, slot, type) -> {
|
||||
config.set(setting.getCompleteKey(), !setting.getBoolean());
|
||||
constructGUI();
|
||||
}));
|
||||
} else if (config.isList(setting.getCompleteKey())) {
|
||||
value.append(setting.getStringList());
|
||||
material = LegacyMaterials.WRITABLE_BOOK.getMaterial();
|
||||
registerClickable(j, ((player1, inventory1, cursor, slot, type) -> {
|
||||
new ConfigListEditorGUI(plugin, player, setting, this);
|
||||
}));
|
||||
} else {
|
||||
value.append("&cPreview Failed");
|
||||
}
|
||||
list.add(value.toString());
|
||||
|
||||
list.addAll(Arrays.asList(setting.getComments()));
|
||||
createButton(j, material, key, list);
|
||||
createButton(j, material, "&c&l" + key, list);
|
||||
}
|
||||
ran.add(key);
|
||||
j++;
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.songoda.core.library.settings.editor;
|
||||
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.library.compatibility.LegacyMaterials;
|
||||
import com.songoda.core.library.settings.Setting;
|
||||
import com.songoda.core.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigListEditorGUI extends AbstractGUI {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final Setting setting;
|
||||
private final ConfigEditorGUI editor;
|
||||
|
||||
private final List<String> stringList;
|
||||
|
||||
public ConfigListEditorGUI(JavaPlugin plugin, Player player, Setting setting, ConfigEditorGUI editor) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.setting = setting;
|
||||
this.stringList = setting.getStringList();
|
||||
this.editor = editor;
|
||||
init("Settings Editor", 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
resetClickables();
|
||||
inventory.clear();
|
||||
for (int i = 0; i < stringList.size(); i++) {
|
||||
int j = i;
|
||||
String item = stringList.get(i);
|
||||
createButton(i, LegacyMaterials.PAPER.getMaterial(), "&7" + item, "&cClick to remove.");
|
||||
registerClickable(i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
stringList.remove(j);
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
createButton(45, LegacyMaterials.LAVA_BUCKET.getMaterial(), "&cDiscard Changes");
|
||||
registerClickable(45, ((player1, inventory1, cursor, slot, type) -> {
|
||||
editor.init("Settings Editor", editor.getInventory().getSize());
|
||||
}));
|
||||
|
||||
createButton(49, LegacyMaterials.CHEST.getMaterial(), "&9Add Item");
|
||||
registerClickable(49, ((player1, inventory1, cursor, slot, type) -> {
|
||||
ChatPrompt prompt = ChatPrompt.showPrompt(plugin, player, "Enter your value.", event ->
|
||||
stringList.add(event.getMessage().trim()));
|
||||
prompt.setOnClose(() -> init("Settings Editor", inventory.getSize()));
|
||||
}));
|
||||
|
||||
createButton(53, LegacyMaterials.REDSTONE.getMaterial(), "&aSave");
|
||||
registerClickable(53, ((player1, inventory1, cursor, slot, type) -> {
|
||||
setting.getConfig().set(setting.getCompleteKey(), stringList);
|
||||
editor.init("Settings Editor", editor.getInventory().getSize());
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.core.library.settings.editor;
|
||||
|
||||
import com.songoda.core.library.compatibility.LegacyMaterials;
|
||||
import com.songoda.core.library.settings.Config;
|
||||
import com.songoda.core.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
@ -20,14 +21,14 @@ public class ConfigSelectionGUI extends AbstractGUI {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.configs.addAll(Arrays.asList(configs));
|
||||
init("test", 54);
|
||||
init("Settings Editor", 9);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
for (int i = 0; i < configs.size(); i++) {
|
||||
Config config = configs.get(i);
|
||||
createButton(i, Material.STONE, config.getConfigName());
|
||||
createButton(i, LegacyMaterials.WRITABLE_BOOK.getMaterial(), "&9&l" + config.getConfigName());
|
||||
registerClickable(i, ((player1, inventory1, cursor, slot, type) ->
|
||||
new ConfigCategoriesGUI(plugin, player, config, this)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user