-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7836d64
commit 8fe1ae3
Showing
2 changed files
with
155 additions
and
81 deletions.
There are no files selected for viewing
155 changes: 155 additions & 0 deletions
155
src/main/java/net/lewmc/kryptonite/kos/config/Spigot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package net.lewmc.kryptonite.kos.config; | ||
|
||
import net.lewmc.kryptonite.Kryptonite; | ||
import net.lewmc.kryptonite.utils.ConfigurationUtil; | ||
import org.bukkit.command.CommandSender; | ||
|
||
/** | ||
* The Spigot class manages the spigot.yml configuration file. | ||
*/ | ||
public class Spigot { | ||
private final Kryptonite plugin; | ||
private final CommandSender user; | ||
|
||
/** | ||
* Constructor for the Spigot class. | ||
* @param plugin Kryptonite - Reference to the main plugin class. | ||
* @param user CommandSender - The user who sent the command. | ||
*/ | ||
public Spigot(Kryptonite plugin, CommandSender user) { | ||
this.plugin = plugin; | ||
this.user = user; | ||
} | ||
|
||
/** | ||
* Configuration values supported by this format. | ||
*/ | ||
public enum Key { | ||
VIEW_DISTANCE { | ||
@Override | ||
public String toString() { return "world-settings.default.view-distance"; } | ||
}, | ||
MOB_SPAWN_RANGE { | ||
@Override | ||
public String toString() { return "world-settings.default.mob-spawn-range"; } | ||
}, | ||
ENTITY_ACTIVATION_RANGE_ANIMALS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.animals"; } | ||
}, | ||
ENTITY_ACTIVATION_RANGE_MONSTERS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.monsters"; } | ||
}, | ||
ENTITY_ACTIVATION_RANGE_RAIDERS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.raiders"; } | ||
}, | ||
ENTITY_ACTIVATION_RANGE_MISC { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.misc"; } | ||
}, | ||
ENTITY_ACTIVATION_RANGE_WATER { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.water"; } | ||
}, | ||
ENTITY_ACTIVATION_RANGE_VILLAGERS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.villagers"; } | ||
}, | ||
ENTITY_ACTIVATION_RANGE_FLYING_MONSTERS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.flying-monsters"; } | ||
}, | ||
ENTITY_TRACKING_RANGE_PLAYERS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-tracking-range.players"; } | ||
}, | ||
ENTITY_TRACKING_RANGE_ANIMALS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-tracking-range.animals"; } | ||
}, | ||
ENTITY_TRACKING_RANGE_MONSTERS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-tracking-range.monsters"; } | ||
}, | ||
ENTITY_TRACKING_RANGE_MISC { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-tracking-range.misc"; } | ||
}, | ||
ENTITY_TRACKING_RANGE_OTHER { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-tracking-range.other"; } | ||
}, | ||
TICK_INACTIVE_VILLAGERS { | ||
@Override | ||
public String toString() { return "world-settings.default.entity-activation-range.tick-inactive-villagers"; } | ||
}, | ||
NERF_SPAWNER_MOBS { | ||
@Override | ||
public String toString() { return "world-settings.default.nerf-spawner-mobs"; } | ||
}, | ||
MERGE_RADIUS_ITEM { | ||
@Override | ||
public String toString() { return "world-settings.default.merge-radius.item"; } | ||
}, | ||
MERGE_RADIUS_EXP { | ||
@Override | ||
public String toString() { return "world-settings.default.merge-radius.exp"; } | ||
}, | ||
TICKS_PER_HOPPER_TRANSFER { | ||
@Override | ||
public String toString() { return "world-settings.default.ticks-per.hopper-transfer"; } | ||
}, | ||
TICKS_PER_HOPPER_CHECK { | ||
@Override | ||
public String toString() { return "world-settings.default.ticks-per.hopper-check"; } | ||
} | ||
} | ||
|
||
/** | ||
* Sets a requested key to a requested value. | ||
* @param key Key - The requested key. | ||
* @param value int - The requested value. | ||
*/ | ||
public void setInt(Bukkit.Key key, int value) { | ||
this.plugin.restartRequired = true; | ||
ConfigurationUtil cfg = new ConfigurationUtil(this.plugin, this.user); | ||
cfg.load("spigot.yml"); | ||
cfg.set(key.toString(), value); | ||
cfg.save(); | ||
} | ||
|
||
/** | ||
* Gets a requested key's value. | ||
* @param key Key - The requested key. | ||
*/ | ||
public int getInt(Bukkit.Key key) { | ||
ConfigurationUtil cfg = new ConfigurationUtil(this.plugin, this.user); | ||
cfg.load("spigot.yml"); | ||
return cfg.getInt(key.toString()); | ||
} | ||
|
||
/** | ||
* Sets a requested key to a requested value. | ||
* @param key Key - The requested key. | ||
* @param value int - The requested value. | ||
*/ | ||
public void setBoolean(Bukkit.Key key, boolean value) { | ||
this.plugin.restartRequired = true; | ||
ConfigurationUtil cfg = new ConfigurationUtil(this.plugin, this.user); | ||
cfg.load("spigot.yml"); | ||
cfg.set(key.toString(), value); | ||
cfg.save(); | ||
} | ||
|
||
/** | ||
* Gets a requested key's value. | ||
* @param key Key - The requested key. | ||
*/ | ||
public boolean getBoolean(Bukkit.Key key) { | ||
ConfigurationUtil cfg = new ConfigurationUtil(this.plugin, this.user); | ||
cfg.load("spigot.yml"); | ||
return cfg.getBoolean(key.toString()); | ||
} | ||
} |
81 changes: 0 additions & 81 deletions
81
src/main/java/net/lewmc/kryptonite/legacy/kos/config/Spigot.java
This file was deleted.
Oops, something went wrong.