Skip to content

Commit

Permalink
test repsy
Browse files Browse the repository at this point in the history
Took 27 minutes
  • Loading branch information
kiranhart committed Nov 17, 2022
1 parent 100bd94 commit 2ad03ae
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 138 deletions.
5 changes: 5 additions & 0 deletions README.md
@@ -0,0 +1,5 @@
![](https://i.imgur.com/0lsV9oR.jpg)
![](https://static.tweetzy.ca/plugins/skulls/about.png)

![](https://static.tweetzy.ca/plugins/skulls/featurebar1.png)
![](https://static.tweetzy.ca/plugins/skulls/featurebar2.png)
19 changes: 12 additions & 7 deletions pom.xml
Expand Up @@ -7,20 +7,25 @@
<artifactId>skulls</artifactId>

<name>Skulls</name>
<version>3.5.2</version>
<version>3.6.0</version>
<packaging>jar</packaging>

<properties>
<author>Kiran Hart</author>
<jarName>Skulls</jarName>
<main.class>${project.groupId}.${project.artifactId}.${project.name}</main.class>
<java.version>1.8</java.version>
<feather.version>3.5.0</feather.version>
<feather.path>ca.tweetzy</feather.path>
<flight.version>3.6.0</flight.version>
<flight.path>ca.tweetzy</flight.path>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>repsy</id>
<name>Tweetzy Maven Repo On Repsy</name>
<url>https://repo.repsy.io/mvn/kiran/tweetzy</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
Expand All @@ -40,9 +45,9 @@
</repositories>
<dependencies>
<dependency>
<groupId>${feather.path}</groupId>
<groupId>${flight.path}</groupId>
<artifactId>flight</artifactId>
<version>${feather.version}</version>
<version>${flight.version}</version>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
Expand Down Expand Up @@ -101,7 +106,7 @@
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>${feather.path}:flight*</include>
<include>${flight.path}:flight*</include>
</includes>
</artifactSet>
<filters>
Expand All @@ -118,7 +123,7 @@
<relocations>
<relocation>
<pattern>ca.tweetzy.flight</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.core</shadedPattern>
<shadedPattern>${project.groupId}.${project.artifactId}.flight</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ca/tweetzy/skulls/Skulls.java
Expand Up @@ -20,10 +20,10 @@

import ca.tweetzy.flight.FlightPlugin;
import ca.tweetzy.flight.command.CommandManager;
import ca.tweetzy.flight.config.tweetzy.TweetzyYamlConfig;
import ca.tweetzy.flight.database.DataMigrationManager;
import ca.tweetzy.flight.database.DatabaseConnector;
import ca.tweetzy.flight.database.SQLiteConnector;
import ca.tweetzy.flight.files.file.YamlFile;
import ca.tweetzy.flight.gui.GuiManager;
import ca.tweetzy.flight.utils.Common;
import ca.tweetzy.skulls.api.SkullsAPI;
Expand All @@ -50,7 +50,7 @@
*/
public final class Skulls extends FlightPlugin {

private final YamlFile coreConfig = new YamlFile(getDataFolder() + "/config.yml");
private final TweetzyYamlConfig coreConfig = new TweetzyYamlConfig(this, "config.yml");

private final GuiManager guiManager = new GuiManager(this);
private final CommandManager commandManager = new CommandManager(this);
Expand Down Expand Up @@ -107,7 +107,7 @@ public static Skulls getInstance() {
}


public static YamlFile getCoreConfig() {
public static TweetzyYamlConfig getCoreConfig() {
return getInstance().coreConfig;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ca/tweetzy/skulls/database/DataManager.java
Expand Up @@ -23,7 +23,7 @@
import ca.tweetzy.flight.database.DatabaseConnector;
import ca.tweetzy.flight.database.UpdateCallback;
import ca.tweetzy.flight.utils.Common;
import ca.tweetzy.skulls.model.Serialize;
import ca.tweetzy.flight.utils.SerializeUtil;
import ca.tweetzy.skulls.Skulls;
import ca.tweetzy.skulls.api.enums.BaseCategory;
import ca.tweetzy.skulls.api.interfaces.*;
Expand Down Expand Up @@ -121,7 +121,7 @@ public void insertPlacedSkull(@NonNull final PlacedSkull placedSkull, Callback<P
fetch.setString(1, placedSkull.getId().toString());
statement.setString(1, placedSkull.getId().toString());
statement.setInt(2, placedSkull.getSkullId());
statement.setString(3, Serialize.serializeLocation(placedSkull.getLocation()));
statement.setString(3, SerializeUtil.serializeLocation(placedSkull.getLocation()));
statement.executeUpdate();

if (callback != null) {
Expand Down Expand Up @@ -389,7 +389,7 @@ public PlacedSkull extractPlacedSkull(@NonNull final ResultSet resultSet) throws
return new PlacedSkullLocation(
UUID.fromString(resultSet.getString("id")),
resultSet.getInt("skull_id"),
Serialize.deserializeLocation(resultSet.getString("location"))
SerializeUtil.deserializeLocation(resultSet.getString("location"))
);
}

Expand Down
55 changes: 0 additions & 55 deletions src/main/java/ca/tweetzy/skulls/model/Serialize.java

This file was deleted.

44 changes: 19 additions & 25 deletions src/main/java/ca/tweetzy/skulls/settings/Locale.java
Expand Up @@ -18,8 +18,7 @@

package ca.tweetzy.skulls.settings;

import ca.tweetzy.flight.files.comments.format.YamlCommentFormat;
import ca.tweetzy.flight.files.file.YamlFile;
import ca.tweetzy.flight.config.tweetzy.TweetzyYamlConfig;
import ca.tweetzy.flight.utils.Common;
import ca.tweetzy.skulls.Skulls;
import lombok.NonNull;
Expand All @@ -41,7 +40,7 @@
@SuppressWarnings("all")
public final class Locale {

private static final Map<String, YamlFile> LOCALES = new HashMap<>();
private static final Map<String, TweetzyYamlConfig> LOCALES = new HashMap<>();
private static final Map<String, Object> PHRASES = new HashMap<>();

private static String defaultLanguage = "english";
Expand All @@ -61,41 +60,36 @@ public static void setup() {
if (file.getName().equalsIgnoreCase("english.yml")) continue;
if (file.getName().equalsIgnoreCase(defaultLanguage + ".yml")) continue;

final YamlFile yamlFile = new YamlFile(Skulls.getInstance().getDataFolder() + "/locales/" + file.getName());
yamlFile.createOrLoadWithComments();
yamlFile.setCommentFormat(YamlCommentFormat.PRETTY);
final TweetzyYamlConfig yamlFile = new TweetzyYamlConfig(Skulls.getInstance(), "/locales/" + file.getName());

PHRASES.forEach((key, value) -> {
if (!yamlFile.isSet(key))
yamlFile.set(key, value);
if (!yamlFile.has(key))
yamlFile.createEntry(key, value);
});

yamlFile.path("file language").set(file.getName().replace(".yml", "")).comment("For internal use, this is auto generated based on file name");
yamlFile.createEntry("file language", file.getName().replace(".yml", "")).withComment("For internal use, this is auto generated based on file name");
yamlFile.init();

yamlFile.save();
LOCALES.put(file.getName().replace(".yml", ""), yamlFile);
}
}

@SneakyThrows
private static void setupDefaults(String name) {
final YamlFile yamlFile = new YamlFile(Skulls.getInstance().getDataFolder() + "/locales/" + name + ".yml");
yamlFile.createOrLoadWithComments();
yamlFile.setCommentFormat(YamlCommentFormat.PRETTY);
final TweetzyYamlConfig yamlFile = new TweetzyYamlConfig(Skulls.getInstance(), "/locales/" + name + ".yml");

PHRASES.forEach((key, value) -> {
if (!yamlFile.isSet(key))
yamlFile.set(key, value);
if (!yamlFile.has(key))
yamlFile.createEntry(key, value);
});

yamlFile.path("file language")
.set(name)
.comment("This is the default language for Skulls to use another language" +
"\nchange the default language in the config.yml" +
"\nif the file does not exists, it will generate using the default english" +
"\ntranslations, you can then make edits from there.");
yamlFile.createEntry("file language", name)
.withComment("This is the default language for Skulls to use another language")
.withComment("change the default language in the config.yml")
.withComment("if the file does not exists, it will generate using the default english")
.withComment("translations, you can then make edits from there.");

yamlFile.save();
yamlFile.init();

LOCALES.put(name, yamlFile);
}
Expand All @@ -117,16 +111,16 @@ public static List<String> getList(String key, String language) {
}

private static Object getPhraseEnglish(String key) {
return LOCALES.get("english").get(key);
return LOCALES.get("english").getOr(key, null);
}

private static Object getPhrase(String key, String language) {
YamlFile file = LOCALES.get(language);
TweetzyYamlConfig file = LOCALES.get(language);

if (file == null)
return getPhraseEnglish(key);

return file.get(key, getPhraseEnglish(key));
return file.getOr(key, getPhraseEnglish(key));
}

public static void tell(CommandSender sender, String key) {
Expand Down

0 comments on commit 2ad03ae

Please sign in to comment.