Skip to content

Commit

Permalink
Merge pull request #6 from NLthijs48/AreaShop_V1.4
Browse files Browse the repository at this point in the history
Adds code of V2.0.2
  • Loading branch information
NLthijs48 committed Sep 24, 2014
2 parents 95e3a4a + 2098b9f commit 8d254e1
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 26 deletions.
3 changes: 2 additions & 1 deletion AreaShop/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
##############################################

########## GENERAL ##########
## Chatprefix used for all messages in the chat
## Chatprefix used for all messages in the chat. Also check the 'greeting' lines in the 'flagProfiles' section,
## these also contain the prefix and you may want to change those to
chatPrefix: '&2[AreaShop]&r '
## The characters used for the prices of regions, will appear before the number, for the euro character use '%euro%'
moneyCharacter: '$'
Expand Down
1 change: 1 addition & 0 deletions AreaShop/lang/EN.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
###################################################
# English language file for the AreaShop plugin #
# Latest update: V2.0.2 #
###################################################
# Copy this file and change the strings to your #
# favor. Then change the 'language' setting in #
Expand Down
265 changes: 265 additions & 0 deletions AreaShop/lang/FR.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion AreaShop/lang/NL.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
###################################################
# Dutch language file for the AreaShop plugin #
# Latest update: V1.2.1 #
###################################################
# Copy this file and change the strings to your #
# favor. Then change the 'language' setting in #
# the config to the filename (excluding .yml) #
# NOT UPDATED since 1.2.1 #
###################################################

########## Command strings
Expand Down
2 changes: 1 addition & 1 deletion AreaShop/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: AreaShop
main: nl.evolutioncoding.AreaShop.AreaShop
version: 2.0.1
version: 2.0.2
depend: [Vault, WorldGuard, WorldEdit]
softdepend: [Multiverse-Core]
commands:
Expand Down
6 changes: 5 additions & 1 deletion AreaShop/src/nl/evolutioncoding/AreaShop/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,14 @@ public void convertFiles() {
saveVersions();
}


// Separate try-catch blocks to try them all individually (don't stop after 1 has failed)
try {
Files.move(new File(rentPath + ".old"), new File(oldFolderPath + "rents.old"));
} catch (Exception e) {}
try {
Files.move(new File(buyPath + ".old"), new File(oldFolderPath + "buys.old"));
} catch (Exception e) {}
try {
Files.move(new File(plugin.getDataFolder() + File.separator + "config.yml"), new File(oldFolderPath + "config.yml"));
} catch (Exception e) {}

Expand Down
47 changes: 32 additions & 15 deletions AreaShop/src/nl/evolutioncoding/AreaShop/LanguageManager.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package nl.evolutioncoding.AreaShop;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.bukkit.configuration.file.YamlConfiguration;

import com.google.common.base.Charsets;

public class LanguageManager {
private AreaShop plugin = null;
private String languages[] = {"EN", "NL"};
private String languages[] = {"EN", "NL", "FR"};
private HashMap<String, String> currentLanguage, defaultLanguage;

/**
Expand Down Expand Up @@ -84,26 +89,38 @@ public void loadLanguage() {
/* Save the current language file to the HashMap */
currentLanguage = new HashMap<String, String>();
File file = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + File.separator + plugin.config().getString("language") + ".yml");
ymlFile = YamlConfiguration.loadConfiguration(file);
map = ymlFile.getValues(true);
set = map.keySet();
InputStreamReader reader = null;
try {
for(String key : set) {
currentLanguage.put(key, (String)map.get(key));
}
} catch(ClassCastException e) {}
reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
} catch (FileNotFoundException e1) {}
if(reader != null) {
ymlFile = YamlConfiguration.loadConfiguration(reader);
map = ymlFile.getValues(true);
set = map.keySet();
try {
for(String key : set) {
currentLanguage.put(key, (String)map.get(key));
}
} catch(ClassCastException e) {}
}

/* Save the default strings to the HashMap */
defaultLanguage = new HashMap<String, String>();
File standard = new File(plugin.getDataFolder() + File.separator + AreaShop.languageFolder + "/" + languages[0]+ ".yml");
ymlFile = YamlConfiguration.loadConfiguration(standard);
map = ymlFile.getValues(true);
set = map.keySet();
InputStreamReader reader2 = null;
try {
for(String key : set) {
defaultLanguage.put(key, (String)map.get(key));
}
} catch(ClassCastException e) {}
reader2 = new InputStreamReader(new FileInputStream(standard), Charsets.UTF_8);
} catch (FileNotFoundException e1) {}
if(reader2 != null) {
ymlFile = YamlConfiguration.loadConfiguration(reader2);
map = ymlFile.getValues(true);
set = map.keySet();
try {
for(String key : set) {
defaultLanguage.put(key, (String)map.get(key));
}
} catch(ClassCastException e) {}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.data.DataException;
import com.sk89q.worldedit.extension.factory.PatternFactory;
import com.sk89q.worldedit.schematic.SchematicFormat;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
import com.sk89q.worldguard.protection.flags.BooleanFlag;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.DoubleFlag;
Expand All @@ -51,6 +51,7 @@
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.StateFlag.State;
import com.sk89q.worldguard.protection.flags.StringFlag;
import com.sk89q.worldguard.protection.managers.storage.StorageException;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;

Expand Down Expand Up @@ -559,13 +560,10 @@ public boolean restoreRegionBlocks(String fileName) {

// The path to save the schematic
File saveFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName + AreaShop.schematicExtension);

LocalSession localSession = new LocalSession(plugin.getWorldEdit().getLocalConfiguration());
editSession.enableQueue();
try {
localSession.setClipboard(SchematicFormat.MCEDIT.load(saveFile));
localSession.getClipboard().place(editSession, origin, false);
} catch (MaxChangedBlocksException | EmptyClipboardException | IOException | DataException e) {
SchematicFormat.MCEDIT.load(saveFile).place(editSession, origin, false);
} catch (MaxChangedBlocksException | IOException | DataException e) {
result = false;
}
editSession.flushQueue();
Expand Down Expand Up @@ -754,7 +752,7 @@ protected boolean setRegionFlags(ConfigurationSection flags) {

try {
worldGuard.getRegionManager(getWorld()).save();
} catch (ProtectionDatabaseException e) {
} catch (StorageException e) {
plugin.getLogger().info("Error: regions could not be saved");
}
return result;
Expand Down

0 comments on commit 8d254e1

Please sign in to comment.