Skip to content

Commit

Permalink
[ci-skip] stash dev environment features
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Sep 18, 2024
1 parent 75999df commit 206e42d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public enum Environment {
PRODUCTION,
ENVIRONMENT
DEVELOPMENT
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.badbones69.crazycrates.common.interfaces;

import com.badbones69.crazycrates.common.enums.Environment;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Manifest {

Environment environment();

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.ryderbelserion.vital.paper.util.AdvUtil;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.List;
Expand Down Expand Up @@ -59,7 +58,7 @@ public void onEnable() {
this.instance = new Server(getDataFolder());
this.instance.apply();

getFileManager().addFile(new File(getDataFolder(), "locations.yml")).addFile(new File(getDataFolder(),"data.yml"))
getFileManager().addFile(new File(getDataFolder(), "locations.yml")).addFile(new File(getDataFolder(), "data.yml"))
.addFolder("crates")
.addFolder("schematics")
.init();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.badbones69.crazycrates.managers.storage;

import com.badbones69.crazycrates.common.enums.Environment;
import com.badbones69.crazycrates.common.interfaces.Manifest;

@Manifest(environment = Environment.DEVELOPMENT)
public class StorageManager {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.badbones69.crazycrates.managers.storage.interfaces;

import com.badbones69.crazycrates.common.enums.Environment;
import com.badbones69.crazycrates.common.interfaces.Manifest;
import java.io.File;

@Manifest(environment = Environment.DEVELOPMENT)
public interface Storage<T> {

T getAccess();

default void start() {}

default void save() {}

default void reload() {}

File getFile();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.badbones69.crazycrates.managers.storage.interfaces;

import com.badbones69.crazycrates.CrazyCrates;
import com.badbones69.crazycrates.common.enums.Environment;
import com.badbones69.crazycrates.common.interfaces.Manifest;
import com.ryderbelserion.vital.paper.api.files.FileManager;
import org.bukkit.configuration.file.YamlConfiguration;

@Manifest(environment = Environment.DEVELOPMENT)
public abstract class YamlStorage implements Storage<YamlConfiguration> {

protected CrazyCrates plugin = CrazyCrates.getPlugin();
protected FileManager fileManager = this.plugin.getFileManager();

@Override
public void start() {
this.fileManager.addFile(getFile());
}

@Override
public void save() {
this.fileManager.saveFile(getFile().getName());
}

@Override
public void reload() {
this.fileManager.addFile(getFile());
}

@Override
public final YamlConfiguration getAccess() {
return this.fileManager.getFile(getFile().getName()).getConfiguration();
}
}

0 comments on commit 206e42d

Please sign in to comment.