forked from EtienneDx/RealEstate
-
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
0 parents
commit 162eff5
Showing
4 changed files
with
266 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.classpath | ||
.project | ||
.settings/* | ||
bin/* |
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,80 @@ | ||
name: RealEstate | ||
main: me.EtienneDx.RealEstate | ||
version: 0.1 | ||
authors: [EtienneDx] | ||
depend: [GriefPrevention, Vault] | ||
|
||
commands: | ||
re: | ||
description: Access to the GriefProtection_RealEstate informations. | ||
usage: /<command> ? | ||
aliases: [realestate] | ||
permission: realestate.info | ||
permission-message: You do not have access to that command! | ||
|
||
permissions: | ||
realestate.*: | ||
description: Gives access to all Real Estate permissions | ||
default: op | ||
children: | ||
realestate.info: true | ||
realestate.admin: true | ||
realestate.claim.buy: true | ||
realestate.claim.sell: true | ||
realestate.claim.rent: true | ||
realestate.claim.lease: true | ||
realestate.subclaim.buy: true | ||
realestate.subclaim.sell: true | ||
realestate.subclaim.rent: true | ||
realestate.subclaim.lease: true | ||
realestate.ignore.limit: true | ||
realestate.claim.*: | ||
description: Allows the player full access over claims | ||
default: op | ||
children: | ||
realestate.claim.buy: true | ||
realestate.claim.sell: true | ||
realestate.claim.rent: true | ||
realestate.claim.lease: true | ||
realestate.subclaim.*: | ||
description: Allows the player full access over subclaims | ||
default: op | ||
children: | ||
realestate.subclaim.buy: true | ||
realestate.subclaim.sell: true | ||
realestate.subclaim.rent: true | ||
realestate.subclaim.lease: true | ||
realestate.admin: | ||
description: Allows the player to have access to Real Estate informations | ||
default: op | ||
realestate.info: | ||
description: Allow the player to get informations about the claim | ||
default: true | ||
realestate.claim.buy: | ||
description: Allows the player to buy claims | ||
default: true | ||
realestate.claim.sell: | ||
description: Allows the player to sell claims | ||
default: true | ||
realestate.claim.rent: | ||
description: Allows the player to rent claims | ||
default: true | ||
realestate.claim.lease: | ||
description: Allows the player to lease claims | ||
default: true | ||
realestate.subclaim.buy: | ||
description: Allows the player to buy subclaims | ||
default: true | ||
realestate.subclaim.sell: | ||
description: Allows the player to sell subclaims | ||
default: true | ||
realestate.subclaim.rent: | ||
description: Allows the player to rent subclaims | ||
default: true | ||
realestate.subclaim.lease: | ||
description: Allows the player to lease subclaims | ||
default: true | ||
realestate.ignore.limit: | ||
description: Allows the player to buy bigger claims than his available claim size | ||
default: false | ||
|
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,65 @@ | ||
package me.EtienneDx.GPRE; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.plugin.PluginDescriptionFile; | ||
|
||
public class DataStore | ||
{ | ||
RealEstate plugin; | ||
public PluginDescriptionFile pdf; | ||
|
||
public final String pluginDirPath = "plugins" + File.separator + "GriefProtection_RealEstate" + File.separator; | ||
public final String configFilePath = this.pluginDirPath + "config.yml"; | ||
public final String logFilePath = this.pluginDirPath + "GriefProtection_RealEstate.log"; | ||
public final String chatPrefix = "[" + ChatColor.GOLD + "RealEstate" + ChatColor.WHITE + "] "; | ||
|
||
public List<String> cfgSigns; | ||
|
||
public List<String> cfgSellKeywords; | ||
public List<String> cfgLeaseKeywords; | ||
|
||
public String cfgReplaceSell; | ||
public String cfgReplaceLease; | ||
|
||
public boolean cfgEnableLease; | ||
public boolean cfgEnableRent; | ||
|
||
public boolean cfgTransferClaimBlocks; | ||
|
||
public boolean cfgMessageOwner; | ||
public boolean cfgBrodcastSell; | ||
|
||
public DataStore(RealEstate plugin) | ||
{ | ||
this.plugin = plugin; | ||
this.pdf = this.plugin.getDescription(); | ||
} | ||
|
||
public String getString(List<String> li) | ||
{ | ||
return String.join(";", li); | ||
} | ||
|
||
public List<String> getList(String str) | ||
{ | ||
return Arrays.asList(str.split(";")); | ||
} | ||
|
||
List<String> getConfigList(YamlConfiguration config, String path, List<String> defVal) | ||
{ | ||
config.addDefault(path, defVal); | ||
return config.getStringList(path); | ||
} | ||
|
||
public void loadConfig(YamlConfiguration config) | ||
{ | ||
this.cfgSigns = getConfigList(config, "RealEstate.Keywords.Signs", Arrays.asList("re", "realestate")); | ||
|
||
this.cfgSigns = getConfigList(config, "RealEstate.Keywords.Signs", Arrays.asList("re", "realestate")); | ||
} | ||
} |
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,117 @@ | ||
package me.EtienneDx.GPRE; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.util.logging.Logger; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.plugin.RegisteredServiceProvider; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import net.milkbowl.vault.economy.Economy; | ||
import net.milkbowl.vault.permission.Permission; | ||
|
||
public class RealEstate extends JavaPlugin | ||
{ | ||
Logger log; | ||
DataStore dataStore; | ||
public static boolean vaultPresent = false; | ||
public static Economy econ = null; | ||
public static Permission perms = null; | ||
|
||
public void onEnable() | ||
{ | ||
this.log = getLogger(); | ||
|
||
if (checkVault()) | ||
{ | ||
this.log.info("Vault has been detected and enabled."); | ||
if (setupEconomy()) | ||
{ | ||
this.log.info("Vault is using " + econ.getName() + " as the economy plugin."); | ||
} | ||
else | ||
{ | ||
this.log.warning("No compatible economy plugin detected [Vault]."); | ||
this.log.warning("Disabling plugin."); | ||
getPluginLoader().disablePlugin(this); | ||
return; | ||
} | ||
if (setupPermissions()) | ||
{ | ||
this.log.info("Vault is using " + perms.getName() + " for the permissions."); | ||
} | ||
else | ||
{ | ||
this.log.warning("No compatible permissions plugin detected [Vault]."); | ||
this.log.warning("Disabling plugin."); | ||
getPluginLoader().disablePlugin(this); | ||
return; | ||
} | ||
} | ||
loadConfig(false); | ||
} | ||
|
||
private void loadConfig(boolean reload) | ||
{ | ||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(this.dataStore.configFilePath)); | ||
FileConfiguration outConfig = new YamlConfiguration(); | ||
|
||
|
||
try | ||
{ | ||
outConfig.save(this.dataStore.configFilePath); | ||
} | ||
catch (IOException exception) | ||
{ | ||
this.log.info("Unable to write to the configuration file at \"" + this.dataStore.configFilePath + "\""); | ||
} | ||
} | ||
|
||
public void addLogEntry(String entry) | ||
{ | ||
try | ||
{ | ||
File logFile = new File(this.dataStore.logFilePath); | ||
if (!logFile.exists()) { | ||
logFile.createNewFile(); | ||
} | ||
FileWriter fw = new FileWriter(logFile, true); | ||
PrintWriter pw = new PrintWriter(fw); | ||
|
||
pw.println(entry); | ||
pw.flush(); | ||
pw.close(); | ||
} | ||
catch (IOException e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private boolean checkVault() | ||
{ | ||
vaultPresent = getServer().getPluginManager().getPlugin("Vault") != null; | ||
return vaultPresent; | ||
} | ||
|
||
private boolean setupEconomy() | ||
{ | ||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class); | ||
if (rsp == null) { | ||
return false; | ||
} | ||
econ = (Economy)rsp.getProvider(); | ||
return econ != null; | ||
} | ||
|
||
private boolean setupPermissions() | ||
{ | ||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class); | ||
perms = (Permission)rsp.getProvider(); | ||
return perms != null; | ||
} | ||
} |