1.14 support

This commit is contained in:
Esophose 2019-04-27 17:58:51 -06:00
parent 24e544d471
commit 74f170b777
4 changed files with 57 additions and 177 deletions

185
.gitignore vendored
View File

@ -1,166 +1,31 @@
# Compiled class file
*.class
out/ # Log file
*.log
\.idea/ # BlueJ files
*.ctxt
EpicFarming\.iml # Mobile Tools for Java (J2ME)
/src/main/resources/META-INF/MANIFEST.MF .mtj.tmp/
/target/
EpicFarming-API/src/main/EpicFarming-API\.iml # Package Files #
*.jar
EpicFarming-Plugin/src/main/EpicFarming-Plugin\.iml *.war
*.nar
EpicFarming-Parent\.iml *.settings
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.gradle/
/.settings/
.idea/
build/
target/
*.iml *.iml
/bin/
EpicFarming-API/target/classes/com/songoda/epicfarming/api/EpicFarming\.class
EpicFarming-API/target/classes/com/songoda/epicfarming/api/EpicFarmingAPI\.class
EpicFarming-API/target/classes/com/songoda/epicfarming/api/farming/Farm\.class
EpicFarming-API/target/classes/com/songoda/epicfarming/api/farming/FarmManager\.class
EpicFarming-API/target/classes/com/songoda/epicfarming/api/farming/Level\.class
EpicFarming-API/target/classes/com/songoda/epicfarming/api/farming/LevelManager\.class
EpicFarming-API/target/classes/com/songoda/epicfarming/api/farming/UpgradeType\.class
EpicFarming-Plugin/pom\.xml
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/boost/BoostData\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/boost/BoostManager\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/AbstractCommand\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/AbstractCommand\$ReturnType\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/CommandManager\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/commands/CommandBoost\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/commands/CommandEpicFarming\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/commands/CommandGiveFarmItem\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/commands/CommandReload\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/command/commands/CommandSettings\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/EpicFarmingPlugin\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/farming/Crop\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/farming/EFarm\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/farming/EFarmManager\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/farming/ELevel\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/farming/ELevelManager\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/HookManager\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookASkyBlock\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookFactions\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookGriefPrevention\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookKingdoms\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookPlotSquared\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookRedProtect\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookSkyBlockEarth\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookTowny\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookUSkyBlock\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/hooks/HookWorldGuard\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/HookType\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/hook/ProtectionPluginHook\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/listeners/BlockListeners\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/listeners/InteractListeners\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/listeners/InventoryListeners\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/Locale\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/player/PlayerActionManager\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/player/PlayerData\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/References\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/storage/Storage\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/storage/StorageItem\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/storage/StorageRow\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/storage/types/StorageMysql\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/storage/types/StorageYaml\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/tasks/EntityTask\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/tasks/EntityTask\$1\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/tasks/FarmTask\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/tasks/GrowthTask\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/tasks/GrowthTask\$1\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/tasks/HopperTask\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/ConfigWrapper\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/CropType\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Debugger\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/EntityInfo\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Methods\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$1\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$2\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$AdvancedBarChart\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$AdvancedPie\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$CustomChart\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$DrilldownPie\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$MultiLineChart\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$SimpleBarChart\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$SimplePie\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Metrics\$SingleLineChart\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/MySQLDatabase\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/Serializers\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/SettingsManager\.class
EpicFarming-Plugin/target/classes/com/songoda/epicfarming/utils/SettingsManager\$settings\.class

View File

@ -4,7 +4,7 @@ stages:
variables: variables:
name: "EpicFarming" name: "EpicFarming"
path: "/builds/$CI_PROJECT_PATH" path: "/builds/$CI_PROJECT_PATH"
version: "2.1.6" version: "2.2"
build: build:
stage: build stage: build

View File

@ -1,22 +1,19 @@
package com.songoda.epicfarming.storage.types; package com.songoda.epicfarming.storage.types;
import com.songoda.epicfarming.EpicFarmingPlugin;
import com.songoda.epicfarming.storage.Storage; import com.songoda.epicfarming.storage.Storage;
import com.songoda.epicfarming.storage.StorageItem; import com.songoda.epicfarming.storage.StorageItem;
import com.songoda.epicfarming.storage.StorageRow; import com.songoda.epicfarming.storage.StorageRow;
import com.songoda.epicfarming.EpicFarmingPlugin;
import com.songoda.epicfarming.utils.Debugger;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemorySection; import org.bukkit.configuration.MemorySection;
import java.io.File; import java.io.*;
import java.io.IOException;
import java.util.*; import java.util.*;
public class StorageYaml extends Storage { public class StorageYaml extends Storage {
private static final Map<String, Object> toSave = new HashMap<>(); private static final Map<String, Object> toSave = new HashMap<>();
private static final Map<String, Object> lastSave = new HashMap<>(); private static Map<String, Object> lastSave = null;
public StorageYaml(EpicFarmingPlugin instance) { public StorageYaml(EpicFarmingPlugin instance) {
super(instance); super(instance);
@ -66,12 +63,13 @@ public class StorageYaml extends Storage {
@Override @Override
public void doSave() { public void doSave() {
this.updateData(instance); this.updateData(instance);
if (lastSave == null)
lastSave = new HashMap<>(toSave);
if (toSave.isEmpty()) return; if (toSave.isEmpty()) return;
Map<String, Object> nextSave = new HashMap<>(toSave); Map<String, Object> nextSave = new HashMap<>(toSave);
if (lastSave.isEmpty())
lastSave.putAll(toSave);
this.makeBackup(); this.makeBackup();
this.save(); this.save();
@ -87,9 +85,9 @@ public class StorageYaml extends Storage {
if (toSave.containsKey(entry.getKey())) { if (toSave.containsKey(entry.getKey())) {
Object newValue = toSave.get(entry.getKey()); Object newValue = toSave.get(entry.getKey());
if (!entry.getValue().equals(newValue)) { if (!entry.getValue().equals(newValue)) {
dataFile.getConfig().set(entry.getKey(), entry.getValue()); dataFile.getConfig().set(entry.getKey(), newValue);
} }
toSave.remove(newValue); toSave.remove(entry.getKey());
} else { } else {
dataFile.getConfig().set(entry.getKey(), null); dataFile.getConfig().set(entry.getKey(), null);
} }
@ -101,7 +99,7 @@ public class StorageYaml extends Storage {
dataFile.saveConfig(); dataFile.saveConfig();
} catch (NullPointerException e) { } catch (NullPointerException e) {
Debugger.runReport(e); e.printStackTrace();
} }
} }
@ -110,9 +108,9 @@ public class StorageYaml extends Storage {
File data = new File(instance.getDataFolder(), "data.yml"); File data = new File(instance.getDataFolder(), "data.yml");
File dataClone = new File(instance.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml"); File dataClone = new File(instance.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
try { try {
FileUtils.copyFile(data, dataClone); copyFile(data, dataClone);
} catch (IOException e) { } catch (IOException e) {
Debugger.runReport(e); e.printStackTrace();
} }
Deque<File> backups = new ArrayDeque<>(); Deque<File> backups = new ArrayDeque<>();
for (File file : Objects.requireNonNull(instance.getDataFolder().listFiles())) { for (File file : Objects.requireNonNull(instance.getDataFolder().listFiles())) {
@ -129,4 +127,21 @@ public class StorageYaml extends Storage {
public void closeConnection() { public void closeConnection() {
dataFile.saveConfig(); dataFile.saveConfig();
} }
private static void copyFile(File source, File dest) throws IOException {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(source);
os = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
} finally {
is.close();
os.close();
}
}
} }

View File

@ -48,14 +48,14 @@ public class SettingsManager implements Listener {
return; return;
} }
if (event.getInventory().getTitle().equals(pluginName + " Settings Manager")) { if (event.getView().getTitle().equals(pluginName + " Settings Manager")) {
event.setCancelled(true); event.setCancelled(true);
if (clickedItem.getType().name().contains("STAINED_GLASS")) return; if (clickedItem.getType().name().contains("STAINED_GLASS")) return;
String type = ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName()); String type = ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName());
this.cat.put((Player) event.getWhoClicked(), type); this.cat.put((Player) event.getWhoClicked(), type);
this.openEditor((Player) event.getWhoClicked()); this.openEditor((Player) event.getWhoClicked());
} else if (event.getInventory().getTitle().equals(pluginName + " Settings Editor")) { } else if (event.getView().getTitle().equals(pluginName + " Settings Editor")) {
event.setCancelled(true); event.setCancelled(true);
if (clickedItem.getType().name().contains("STAINED_GLASS")) return; if (clickedItem.getType().name().contains("STAINED_GLASS")) return;