Skip to content

Commit

Permalink
updated to 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNavaStar authored Jun 15, 2021
1 parent 5d69c42 commit ded60b4
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 70 deletions.
12 changes: 6 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)

Copyright (c) 2021 ethans0061
Copyright (c) 2021

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
25 changes: 12 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.7-SNAPSHOT'
id 'fabric-loom' version '0.8.1'
id 'maven-publish'
}

Expand All @@ -16,41 +16,40 @@ repositories {
}

dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

//For formatting JSON
compile 'com.github.javadev:underscore:1.64'
implementation 'com.github.javadev:underscore:1.64'
include 'com.github.javadev:underscore:1.64'

//SQL
implementation 'org.xerial:sqlite-jdbc:3.34.0'
include 'org.xerial:sqlite-jdbc:3.34.0'

//Addon Mods
modImplementation 'com.github.Gegy:player-roles:b0b68135723f0c3bfb26489d06b9c956f4595de3'
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
Expand Down Expand Up @@ -79,4 +78,4 @@ publishing {
// uncomment to publish to the local maven
// mavenLocal()
}
}
}
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.5
minecraft_version=1.17
yarn_mappings=1.17+build.7
loader_version=0.11.3
# Mod Properties
mod_version=1.1.1
mod_version=1.2
maven_group=mrnavastar
archives_base_name=invsync
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.25.1+build.416-1.16
fabric_version=0.34.9+1.17
6 changes: 1 addition & 5 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pluginManagement {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'

}
gradlePluginPortal()
}
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/com/mrnavastar/invsync/Invsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

import com.mrnavastar.invsync.setup.ConfigManager;
import com.mrnavastar.invsync.setup.PlayerDataSetup;
import com.mrnavastar.invsync.setup.PlayerRolesSetup;
import com.mrnavastar.invsync.sql.SQLHandler;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Invsync implements ModInitializer {

public static final String MODID = "invsync";
public static final String databaseName = ConfigManager.Database_Name;

@Override
public void onInitialize() {
Expand All @@ -30,16 +26,6 @@ public void onInitialize() {
SQLHandler.disconnect();

PlayerDataSetup.start();

//Enable syncing for supported mods when present
for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
if (modContainer.getMetadata().getId().equals("player_roles") && ConfigManager.Sync_Player_Roles) {
log(Level.INFO, "Player Roles found! Enabling support");
PlayerRolesSetup.start();
} else {
SQLHandler.dropTable(ConfigManager.Player_Roles_Table_Name);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.player.HungerManager;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.StringNbtReader;

public class ConversionHelpers {

public static String itemStackToString(ItemStack item) {
String itemData = item.toTag(new CompoundTag()).toString();
String itemData = item.writeNbt(new NbtCompound()).toString();
return itemData.replace("'", "$");
}

public static String foodLevelToString(HungerManager hungerManager) {
CompoundTag tag = new CompoundTag();
hungerManager.toTag(tag);
NbtCompound tag = new NbtCompound();
hungerManager.writeNbt(tag);
return tag.toString();
}

public static String effectsToString(StatusEffectInstance effectInstance) {
CompoundTag tag = new CompoundTag();
effectInstance.toTag(tag);
NbtCompound tag = new NbtCompound();
effectInstance.writeNbt(tag);
return tag.toString();
}

public static CompoundTag stringToTag(String nbt) {
CompoundTag tag = null;
public static NbtCompound stringToTag(String nbt) {
NbtCompound tag = null;
try {
tag = StringNbtReader.parse(nbt.replace("$", "'"));
} catch (CommandSyntaxException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public static void nbtToSql(PlayerEntity player) {

if (ConfigManager.Sync_Inv) {
for (int i = 0; i < 36; i++) {
playerDataTable.set(uuid, "inv" + i, ConversionHelpers.itemStackToString(player.inventory.main.get(i)));
playerDataTable.set(uuid, "inv" + i, ConversionHelpers.itemStackToString(player.getInventory().main.get(i)));
}
playerDataTable.set(uuid, "offHand", ConversionHelpers.itemStackToString(player.inventory.offHand.get(0)));
playerDataTable.set(uuid, "selectedSlot", player.inventory.selectedSlot);
playerDataTable.set(uuid, "offHand", ConversionHelpers.itemStackToString(player.getInventory().offHand.get(0)));
playerDataTable.set(uuid, "selectedSlot", player.getInventory().selectedSlot);
}

if (ConfigManager.Sync_Armour) {
for (int i = 0; i < 4; i++) {
playerDataTable.set(uuid, "armour" + i, ConversionHelpers.itemStackToString(player.inventory.armor.get(i)));
playerDataTable.set(uuid, "armour" + i, ConversionHelpers.itemStackToString(player.getInventory().armor.get(i)));
}
}

Expand Down Expand Up @@ -70,25 +70,25 @@ public static void sqlToNbt(PlayerEntity player) {

if (ConfigManager.Sync_Inv) {
for (int i = 0; i < 36; i++) {
player.inventory.main.set(i, ItemStack.fromTag(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "inv" + i, ConversionHelpers.itemStackToString(player.inventory.main.get(i))))));
player.getInventory().main.set(i, ItemStack.fromNbt(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "inv" + i, ConversionHelpers.itemStackToString(player.getInventory().main.get(i))))));
}
player.inventory.offHand.set(0, ItemStack.fromTag(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "offHand", ConversionHelpers.itemStackToString(player.inventory.offHand.get(0))))));
player.getInventory().offHand.set(0, ItemStack.fromNbt(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "offHand", ConversionHelpers.itemStackToString(player.getInventory().offHand.get(0))))));

player.inventory.selectedSlot = playerDataTable.get(uuid, "selectedSlot", player.inventory.selectedSlot);
player.getInventory().selectedSlot = playerDataTable.get(uuid, "selectedSlot", player.getInventory().selectedSlot);
}

if (ConfigManager.Sync_Armour) {
for (int i = 0; i < 4; i++) {
player.inventory.armor.set(i, ItemStack.fromTag(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "armour" + i, ConversionHelpers.itemStackToString(player.inventory.armor.get(i))))));
player.getInventory().armor.set(i, ItemStack.fromNbt(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "armour" + i, ConversionHelpers.itemStackToString(player.getInventory().armor.get(i))))));
}
}

if (ConfigManager.Sync_eChest) {
for (int i = 0; i < 27; i++) {
player.getEnderChestInventory().setStack(i, ItemStack.fromTag(ConversionHelpers.stringToTag(playerDataTable
player.getEnderChestInventory().setStack(i, ItemStack.fromNbt(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "eChest" + i, ConversionHelpers.itemStackToString(player.getEnderChestInventory().getStack(i))))));
}
}
Expand All @@ -107,7 +107,7 @@ public static void sqlToNbt(PlayerEntity player) {
}

if (ConfigManager.Sync_Food_Level) {
player.getHungerManager().fromTag(ConversionHelpers.stringToTag(playerDataTable
player.getHungerManager().readNbt(ConversionHelpers.stringToTag(playerDataTable
.get(uuid, "foodLevel", ConversionHelpers.foodLevelToString(player.getHungerManager()))));
}

Expand All @@ -117,7 +117,7 @@ public static void sqlToNbt(PlayerEntity player) {
if (!str.equals("[]")) {
String[] strArr = str.replace("[", "").replace("]", "").split(", ");
for (String s : strArr) {
player.addStatusEffect(StatusEffectInstance.fromTag(ConversionHelpers.stringToTag(s)));
player.addStatusEffect(StatusEffectInstance.fromNbt(ConversionHelpers.stringToTag(s)));
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
"depends": {
"fabricloader": ">=0.10.5",
"minecraft": [
"1.16.5",
"1.16.4",
"1.16.3",
"1.16.2",
"1.16.1"
"1.17"
]
}
}

0 comments on commit ded60b4

Please sign in to comment.