This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
11 changed files
with
429 additions
and
32 deletions.
There are no files selected for viewing
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
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
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,59 @@ | ||
package dev.oxs.staffchat; | ||
|
||
// thank you johnymuffin | ||
|
||
import org.bukkit.util.config.Configuration; | ||
|
||
import java.io.File; | ||
import java.util.HashMap; | ||
|
||
public class StaffChatLanguage extends Configuration { | ||
private HashMap<String, String> map; | ||
|
||
public StaffChatLanguage(File file, boolean dev) { | ||
super(file); | ||
map = new HashMap<String, String>(); | ||
loadDefaults(); | ||
if(!dev) { | ||
loadFile(); | ||
} | ||
} | ||
|
||
private void loadDefaults() { | ||
map.put("no_permission", "&4Sorry, you don't have permission for this command."); | ||
map.put("no_permission_other", "&4%player% &cdoes not have permission for this command."); | ||
map.put("staffchat_usage", "&cUsage: /sc <message>"); | ||
map.put("publicchat_usage", "&cUsage: /pc <message>"); | ||
map.put("staffchat_toggle", "&7You have turned staff chat %status%&7."); | ||
map.put("staffchat_togglejoin", "%prefix% &7Hello &f%player%&7, currently have staff chat %status%&7."); | ||
map.put("staffchat_check", "&7You currently have staff chat %status%&7."); | ||
map.put("staffchat_check_other", "&f%player% &7currently has staff chat %status%&7."); | ||
map.put("staffchat_check_online", "&4%player% &cis not online."); | ||
map.put("staffchat_menu", "&7--------- %prefix% &7---------" + | ||
"\n&7Version: &f%version%" + | ||
"\n&7Description: &f%description%" + | ||
"\n&7Author(s): &f%author%"); | ||
} | ||
|
||
private void loadFile() { | ||
this.load(); | ||
for (String key : map.keySet()) { | ||
if (this.getString(key) == null) { | ||
this.setProperty(key, map.get(key)); | ||
} else { | ||
map.put(key, this.getString(key)); | ||
} | ||
} | ||
this.save(); | ||
} | ||
|
||
public String getMessage(String msg) { | ||
String loc = map.get(msg); | ||
if (loc != null) { | ||
return loc.replace("&", "\u00a7"); | ||
} | ||
return msg; | ||
} | ||
|
||
|
||
} |
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
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,110 @@ | ||
package dev.oxs.staffchat; | ||
|
||
// thank you johnymuffin | ||
|
||
import org.bukkit.util.config.Configuration; | ||
|
||
import java.io.File; | ||
|
||
public class StaffChatSettings extends Configuration { | ||
private static StaffChatSettings singleton; | ||
|
||
private StaffChatSettings(StaffChat plugin) { | ||
super(new File(plugin.getDataFolder(), "settings.yml")); | ||
this.reload(); | ||
} | ||
|
||
private void write() { | ||
//Main | ||
generateConfigOption("config-version", 1); | ||
//Setting | ||
generateConfigOption("settings.staffchat-prefix", "&c[StaffChat]&f"); | ||
generateConfigOption("settings.staffchat-toggle-alert", true); | ||
generateConfigOption("settings.staffchat-use-displayNamesStaffChat", false); | ||
generateConfigOption("settings.staffchat-use-displayNamesPublicChat", true); | ||
generateConfigOption("settings.staffchat-publicChatPrefix", "&f<%player%&f> "); | ||
} | ||
|
||
public void generateConfigOption(String key, Object defaultValue) { | ||
if (this.getProperty(key) == null) { | ||
this.setProperty(key, defaultValue); | ||
} | ||
final Object value = this.getProperty(key); | ||
this.removeProperty(key); | ||
this.setProperty(key, value); | ||
} | ||
|
||
//Getters Start | ||
public Object getConfigOption(String key) { | ||
return this.getProperty(key); | ||
} | ||
|
||
public String getConfigString(String key) { | ||
return String.valueOf(getConfigOption(key)); | ||
} | ||
|
||
public Integer getConfigInteger(String key) { | ||
return Integer.valueOf(getConfigString(key)); | ||
} | ||
|
||
public Long getConfigLong(String key) { | ||
return Long.valueOf(getConfigString(key)); | ||
} | ||
|
||
public Double getConfigDouble(String key) { | ||
return Double.valueOf(getConfigString(key)); | ||
} | ||
|
||
public Boolean getConfigBoolean(String key) { | ||
return Boolean.valueOf(getConfigString(key)); | ||
} | ||
|
||
|
||
//Getters End | ||
public Long getConfigLongOption(String key) { | ||
if (this.getConfigOption(key) == null) { | ||
return null; | ||
} | ||
return Long.valueOf(String.valueOf(this.getProperty(key))); | ||
} | ||
|
||
|
||
private boolean convertToNewAddress(String newKey, String oldKey) { | ||
if (this.getString(newKey) != null) { | ||
return false; | ||
} | ||
if (this.getString(oldKey) == null) { | ||
return false; | ||
} | ||
System.out.println("Converting Config: " + oldKey + " to " + newKey); | ||
Object value = this.getProperty(oldKey); | ||
this.setProperty(newKey, value); | ||
this.removeProperty(oldKey); | ||
return true; | ||
|
||
} | ||
|
||
|
||
private void reload() { | ||
this.load(); | ||
this.write(); | ||
this.save(); | ||
} | ||
|
||
@Deprecated | ||
public static StaffChatSettings getInstance() { | ||
if (StaffChatSettings.singleton == null) { | ||
throw new RuntimeException("A instance of StaffChat hasn't been passed into StaffChatConfig yet."); | ||
} | ||
return StaffChatSettings.singleton; | ||
} | ||
|
||
@Deprecated | ||
public static StaffChatSettings getInstance(StaffChat plugin) { | ||
if (StaffChatSettings.singleton == null) { | ||
StaffChatSettings.singleton = new StaffChatSettings(plugin); | ||
} | ||
return StaffChatSettings.singleton; | ||
} | ||
|
||
} |
Oops, something went wrong.