Skip to content

Commit

Permalink
Remove module download functionality from Sponge Version. Add SQLite …
Browse files Browse the repository at this point in the history
…connector.
  • Loading branch information
creatorfromhell committed Nov 17, 2023
1 parent 7a0dc38 commit 57ac82c
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Core/src/net/tnemc/core/io/storage/engine/sql/MySQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public String url(String file, String host, int port, String database) {
*/
@Override
public Map<String, Object> properties() {
Map<String, Object> properties = new HashMap<>();
final Map<String, Object> properties = new HashMap<>();

properties.put("autoReconnect", true);
properties.put("cachePrepStmts", true);
Expand Down
81 changes: 81 additions & 0 deletions Core/src/net/tnemc/core/io/storage/engine/sql/SQLite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package net.tnemc.core.io.storage.engine.sql;

/*
* The New Economy
* Copyright (C) 2022 - 2023 Daniel "creatorfromhell" Vidmar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import net.tnemc.core.config.DataConfig;
import net.tnemc.core.io.storage.Dialect;
import net.tnemc.core.io.storage.SQLEngine;
import net.tnemc.core.io.storage.engine.StandardSQL;

import java.util.HashMap;
import java.util.Map;

public class SQLite extends StandardSQL {

public SQLite() {
super();
}

public SQLite(final String prefix, Dialect dialect) {
super(prefix, dialect);
}

/**
* The name of this engine.
*
* @return The engine name.
*/
@Override
public String name() {
return "sqlite";
}

@Override
public String[] driver() {
return new String[] {
"org.sqlite.JDBC"
};
}

@Override
public String[] dataSource() {
return new String[0];
}

@Override
public String url(String file, String host, int port, String database) {
return "jdbc:sqlite:" + file;
}

/**
* Used to get addition hikari properties for this {@link SQLEngine}.
* @return A map containing the additional properties.
*/
@Override
public Map<String, Object> properties() {
final Map<String, Object> properties = new HashMap<>();

properties.put("cachePrepStmts", true);
properties.put("prepStmtCacheSize", 250);
properties.put("prepStmtCacheSqlLimit", 2048);
properties.put("rewriteBatchedStatements", true);
properties.put("useServerPrepStmts", true);
return properties;
}
}
4 changes: 2 additions & 2 deletions Core/src/net/tnemc/core/module/ModuleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void load() {
TNECore.log().inform("Found module: " + wrapper.name() + " version: " + wrapper.version());
modules.put(wrapper.name(), wrapper);

if (!wrapper.getInfo().updateURL().trim().equalsIgnoreCase("")) {
if(!TNECore.server().name().equalsIgnoreCase("sponge") && !wrapper.getInfo().updateURL().trim().equalsIgnoreCase("")) {
TNECore.log().inform("Checking for updates for module " + wrapper.info.name());
ModuleUpdateChecker checker = new ModuleUpdateChecker(wrapper.info.name(), wrapper.info.updateURL(), wrapper.version());
checker.check();
Expand Down Expand Up @@ -116,7 +116,7 @@ public boolean load(String moduleName) {
TNECore.log().inform("Found module: " + wrapper.name() + " version: " + wrapper.version());
modules.put(wrapper.name(), wrapper);

if(!wrapper.getInfo().updateURL().trim().equalsIgnoreCase("")) {
if(!TNECore.server().name().equalsIgnoreCase("sponge") && !wrapper.getInfo().updateURL().trim().equalsIgnoreCase("")) {
TNECore.log().inform("Checking for updates for module " + moduleName);
ModuleUpdateChecker checker = new ModuleUpdateChecker(moduleName, wrapper.info.updateURL(), wrapper.version());
checker.check();
Expand Down
2 changes: 1 addition & 1 deletion Sponge8/resources/META-INF/sponge_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"license": "AGPL",
"global": {
"version": "0.1.2.6-Pre1",
"version": "0.1.2.5-Pre10",
"links": {
"homepage": "https://tnemc.net",
"source": "https://github.com/TheNewEconomy/EconomyCore",
Expand Down
24 changes: 0 additions & 24 deletions Sponge8/src/net/tnemc/sponge/command/ModuleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@
@Command({"module", "mod"})
public class ModuleCommand {

@Subcommand({"avail", "available"})
@Usage("#{Module.Available.Arguments}")
@Description("#{Module.Available.Description}")
@CommandPermission("tne.module.available")
public void onAvailable(SpongeCommandActor sender, @Default(TNECore.coreURL) String url) {
net.tnemc.core.command.ModuleCommand.onAvailable(new SpongeCMDSource(sender), url);
}

@Subcommand({"download", "dl"})
@Usage("#{Module.Download.Arguments}")
@Description("#{Module.Download.Description}")
@CommandPermission("tne.module.download")
public void onDownload(SpongeCommandActor sender, String moduleName, @Default(TNECore.coreURL) String url) {
net.tnemc.core.command.ModuleCommand.onDownload(new SpongeCMDSource(sender), moduleName, url);
}

@Subcommand({"info", "i"})
@Usage("#{Module.Info.Arguments}")
@Description("#{Module.Info.Description}")
Expand All @@ -69,12 +53,4 @@ public void onInfo(SpongeCommandActor sender, String moduleName) {
public void onList(SpongeCommandActor sender) {
net.tnemc.core.command.ModuleCommand.onList(new SpongeCMDSource(sender));
}

@Subcommand({"load"})
@Usage("#{Module.Load.Arguments}")
@Description("#{Module.Load.Description}")
@CommandPermission("tne.module.load")
public void onLoad(SpongeCommandActor sender, String moduleName) {
net.tnemc.core.command.ModuleCommand.onLoad(new SpongeCMDSource(sender), moduleName);
}
}

0 comments on commit 57ac82c

Please sign in to comment.