mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-12-17 22:17:37 +01:00
Merge branch 'Testing' of gitlab.com:Songoda/songodaupdater into Testing
This commit is contained in:
commit
0f2cd764c3
@ -11,7 +11,7 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<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-SNAPSHOT" 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" name="Maven: net.milkbowl:vault:1.7.1" level="project" />
|
||||
|
21
pom.xml
21
pom.xml
@ -21,18 +21,23 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<url>http://68.183.129.248/artifactory/private/</url>
|
||||
<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>
|
||||
|
@ -117,7 +117,7 @@ public class SongodaCore {
|
||||
|
||||
private void update(PluginInfo plugin) {
|
||||
try {
|
||||
URL url = new URL("http://update.songoda.com/index.php?plugin=" + plugin.getSongodaId()
|
||||
URL url = new URL("https://update.songoda.com/index.php?plugin=" + plugin.getSongodaId()
|
||||
+ "&version=" + plugin.getJavaPlugin().getDescription().getVersion()
|
||||
+ "&updaterVersion=" + updaterVersion);
|
||||
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
|
||||
|
@ -69,7 +69,8 @@ public class ChatPrompt implements Listener {
|
||||
handler.onChat(chatConfirmEvent);
|
||||
|
||||
if (onClose != null) {
|
||||
onClose.onClose();
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
onClose.onClose(), 0L);
|
||||
}
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
@ -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;
|
||||
@ -155,7 +156,9 @@ public class Config {
|
||||
for (String categoryStr : fileConfiguration.getKeys(false)) {
|
||||
Category category = new Category(this, categoryStr);
|
||||
for (String settingStr : fileConfiguration.getConfigurationSection(categoryStr).getKeys(true)) {
|
||||
category.addSetting(settingStr, fileConfiguration.get(categoryStr + "." + settingStr));
|
||||
Object object = fileConfiguration.get(categoryStr + "." + settingStr);
|
||||
if (!(object instanceof MemorySection))
|
||||
category.addSetting(settingStr, object);
|
||||
}
|
||||
addCategory(category);
|
||||
}
|
||||
@ -177,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() {
|
||||
@ -303,7 +305,8 @@ public class Config {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
fileConfiguration.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,14 @@ public class Setting {
|
||||
return getConfig().getString(getCompleteKey());
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return getString(null);
|
||||
}
|
||||
|
||||
public Object getObject(Object def) {
|
||||
return getConfig().get(getCompleteKey());
|
||||
}
|
||||
|
||||
public char getChar() {
|
||||
return getChar('0');
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import java.util.*;
|
||||
/**
|
||||
* Created by songoda on 6/4/2017.
|
||||
*/
|
||||
public class SettingsManager implements Listener {
|
||||
public class SettingsManagerOld implements Listener {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final Config config;
|
||||
@ -30,7 +30,7 @@ public class SettingsManager implements Listener {
|
||||
private Map<Player, String> cat = new HashMap<>();
|
||||
private Map<Player, String> current = new HashMap<>();
|
||||
|
||||
public SettingsManager(Config config) {
|
||||
public SettingsManagerOld(Config config) {
|
||||
this.plugin = config.getPlugin();
|
||||
this.config = config;
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
@ -0,0 +1,56 @@
|
||||
package com.songoda.core.library.settings.editor;
|
||||
|
||||
import com.songoda.core.library.compatibility.LegacyMaterials;
|
||||
import com.songoda.core.library.settings.Category;
|
||||
import com.songoda.core.library.settings.Config;
|
||||
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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigCategoriesGUI extends AbstractGUI {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final Config config;
|
||||
private final ConfigSelectionGUI selection;
|
||||
|
||||
public ConfigCategoriesGUI(JavaPlugin plugin, Player player, Config config, ConfigSelectionGUI selection) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.selection = selection;
|
||||
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("Settings Editor", selection.getInventory().getSize())));
|
||||
|
||||
for (int i = 9; i - 9 < config.getCategories().size(); i++) {
|
||||
Category category = config.getCategories().get(i - 9);
|
||||
createButton(i, LegacyMaterials.WRITABLE_BOOK.getMaterial(), "&9&l" + category.getKey());
|
||||
registerClickable(i, ((player1, inventory1, cursor, slot, type) ->
|
||||
new ConfigEditorGUI(plugin, player, category, null, this)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
|
||||
public Config getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
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.FoundSetting;
|
||||
import com.songoda.core.library.settings.Narrow;
|
||||
import com.songoda.core.library.settings.Setting;
|
||||
import com.songoda.core.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigEditorGUI extends AbstractGUI {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final Narrow narrow;
|
||||
private final String narrowed;
|
||||
private final ConfigCategoriesGUI categories;
|
||||
|
||||
public ConfigEditorGUI(JavaPlugin plugin, Player player, Narrow narrow, String narrowed, ConfigCategoriesGUI categories) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.narrow = narrow;
|
||||
this.narrowed = narrowed;
|
||||
this.categories = categories;
|
||||
init("Settings Editor", 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
resetClickables();
|
||||
|
||||
createButton(0, LegacyMaterials.getMaterial("OAK_FENCE_GATE").getMaterial(), "Back");
|
||||
registerClickable(0, ((player1, inventory1, cursor, slot, type) ->
|
||||
categories.init("Settings Editor", categories.getInventory().getSize())));
|
||||
|
||||
List<String> ran = new ArrayList<>();
|
||||
int j = 9;
|
||||
for (int i = 0; i < narrow.getSettings().size(); i++) {
|
||||
FoundSetting setting = narrow.getSettings().get(i);
|
||||
boolean canNarrow = setting.getKey().replace(narrowed == null ? "" : narrowed + ".", "").contains(".");
|
||||
String key = canNarrow ? splitByLast(setting.getKey()) : setting.getKey();
|
||||
|
||||
if (!ran.contains(key)) {
|
||||
if (canNarrow) {
|
||||
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 {
|
||||
FileConfiguration config = setting.getConfig();
|
||||
Material material = Material.STONE;
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
StringBuilder value = new StringBuilder("&a");
|
||||
if (config.isString(setting.getCompleteKey())) {
|
||||
value.append(setting.getString());
|
||||
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("Settings Editor", inventory.getSize()));
|
||||
}));
|
||||
} else if (isNumber(setting)) {
|
||||
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())) {
|
||||
config.set(setting.getCompleteKey(), Integer.parseInt(event.getMessage().trim()));
|
||||
} else if (config.isDouble(setting.getCompleteKey())) {
|
||||
config.set(setting.getCompleteKey(), Double.parseDouble(event.getMessage().trim()));
|
||||
} else if (config.isLong(setting.getCompleteKey())) {
|
||||
config.set(setting.getCompleteKey(), Long.parseLong(event.getMessage().trim()));
|
||||
}
|
||||
});
|
||||
prompt.setOnClose(() -> init("Settings Editor", inventory.getSize()));
|
||||
}));
|
||||
if (config.isInt(setting.getCompleteKey())) {
|
||||
value.append(setting.getInt());
|
||||
} else if (config.isDouble(setting.getCompleteKey())) {
|
||||
value.append(setting.getDouble());
|
||||
} else if (config.isLong(setting.getCompleteKey())) {
|
||||
value.append(setting.getLong());
|
||||
}
|
||||
} else if (config.isBoolean(setting.getCompleteKey())) {
|
||||
value.append(setting.getBoolean());
|
||||
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, "&c&l" + key, list);
|
||||
}
|
||||
ran.add(key);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
categories.getConfig().save();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
|
||||
private boolean isNumber(Setting setting) {
|
||||
FileConfiguration config = setting.getConfig();
|
||||
return config.isInt(setting.getCompleteKey())
|
||||
|| config.isDouble(setting.getCompleteKey())
|
||||
|| config.isLong(setting.getCompleteKey());
|
||||
}
|
||||
|
||||
private String splitByLast(String toSplit) {
|
||||
int index = toSplit.lastIndexOf(".");
|
||||
return toSplit.substring(0, index);
|
||||
}
|
||||
}
|
@ -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() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
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;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigSelectionGUI extends AbstractGUI {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
private final List<Config> configs = new ArrayList<>();
|
||||
|
||||
public ConfigSelectionGUI(JavaPlugin plugin, Player player, Config... configs) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.configs.addAll(Arrays.asList(configs));
|
||||
init("Settings Editor", 9);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
for (int i = 0; i < configs.size(); i++) {
|
||||
Config config = configs.get(i);
|
||||
createButton(i, LegacyMaterials.WRITABLE_BOOK.getMaterial(), "&9&l" + config.getConfigName());
|
||||
registerClickable(i, ((player1, inventory1, cursor, slot, type) ->
|
||||
new ConfigCategoriesGUI(plugin, player, config, this)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user