Skip to content

Commit

Permalink
Fixed OSS constructing with quest 0 task 0 instead of -1
Browse files Browse the repository at this point in the history
Fixed OSS not accepting piped items
Added better leniency to duplicate supporter entries
Added more WIP code to theme uncataloguing system
  • Loading branch information
Funwayguy committed Mar 9, 2020
1 parent 3b62cce commit bd021e7
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ minecraft {
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modGroup = betterquesting
modVersion = 3.5.320
modVersion = 3.5.323
modBaseName = BetterQuesting
modBaseClass = BetterQuesting.java

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/betterquesting/api2/supporter/SupporterDB.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package betterquesting.api2.supporter;

import betterquesting.api2.storage.INBTSaveLoad;
import betterquesting.core.BetterQuesting;
import net.minecraft.nbt.NBTTagCompound;

import javax.annotation.Nonnull;
Expand All @@ -14,19 +15,20 @@ public class SupporterDB implements INBTSaveLoad<NBTTagCompound>

private final TreeMap<UUID, SupporterEntry> mapDB = new TreeMap<>();

public synchronized SupporterEntry add(@Nonnull UUID uuid)
public synchronized SupporterEntry add(@Nonnull UUID playerID)
{
SupporterEntry entry = new SupporterEntry();
if(mapDB.putIfAbsent(uuid, entry) != null)
if(mapDB.putIfAbsent(playerID, entry) != null)
{
throw new IllegalArgumentException("ID or value is already contained within database");
BetterQuesting.logger.warn("Tried to add duplicate supporter to DB: " + playerID.toString());
return mapDB.get(playerID);
}
return entry;
}

public synchronized boolean removeID(@Nonnull UUID uuid)
public synchronized boolean removeID(@Nonnull UUID playerID)
{
return mapDB.remove(uuid) != null;
return mapDB.remove(playerID) != null;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package betterquesting.api2.supporter.theme_dlc;

import betterquesting.api.utils.JsonHelper;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.util.ResourceLocation;

import javax.annotation.Nonnull;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;

public class CatalogueEntry
Expand All @@ -13,6 +19,9 @@ public class CatalogueEntry
public final ResourceLocation themeID;
public final String downloadLink;

public final List<String> reqMods = new ArrayList<>();
public final List<String> reqThemes = new ArrayList<>();

private String token;
private String service;
private int subTier;
Expand All @@ -36,6 +45,30 @@ public CatalogueEntry setRequirement(@Nonnull String token, @Nonnull String serv
return this;
}

public CatalogueEntry(@Nonnull JsonObject json)
{
this.author = JsonHelper.GetString(json, "author", "Unknown");
this.name = JsonHelper.GetString(json, "themeName", "Untitled");
this.themeID = new ResourceLocation(JsonHelper.GetString(json, "themeID", "minecraft:untitled"));
this.downloadLink = JsonHelper.GetString(json, "themeID", "127.0.0.1");

reqMods.clear();
JsonArray aryMods = JsonHelper.GetArray(json, "reqMods");
for(JsonElement je : aryMods)
{
if(!je.isJsonPrimitive() || !je.getAsJsonPrimitive().isString()) continue;
reqMods.add(je.getAsString());
}

reqMods.clear();
JsonArray aryThms = JsonHelper.GetArray(json, "reqThemes");
for(JsonElement je : aryThms)
{
if(!je.isJsonPrimitive() || !je.getAsJsonPrimitive().isString()) continue;
reqThemes.add(je.getAsString());
}
}

public Future<File> downloadTheme()
{
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package betterquesting.api2.supporter.theme_dlc;

import betterquesting.api.utils.JsonHelper;
import com.google.gson.JsonObject;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ThemeRepository
{
private final String repoAddress;
public String repoName = "Unknown Theme Repository";

private final List<CatalogueEntry> entries = new ArrayList<>();

public ThemeRepository(@Nonnull String address)
{
repoAddress = address;
}

public String getAddress()
{
return this.repoAddress;
}

public List<CatalogueEntry> getEntries()
{
return Collections.unmodifiableList(entries);
}

public void loadRepository(@Nonnull JsonObject json)
{
repoName = JsonHelper.GetString(json, "repoName", "Unknown Repository");
}
}
2 changes: 1 addition & 1 deletion src/main/java/betterquesting/blocks/SSItemHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate
// Existing stack
ItemStack ts1 = getStackInSlot(slot);

if(!stack.isItemEqual(ts1))
if(!ts1.isEmpty() && !stack.isItemEqual(ts1))
{
return stack;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/betterquesting/blocks/TileSubmitStation.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public class TileSubmitStation extends TileEntity implements IFluidHandler, ISid
private final IFluidHandler fluidHandler;
private NonNullList<ItemStack> itemStack = NonNullList.withSize(2, ItemStack.EMPTY);
private boolean needsUpdate = false;
public UUID owner;
public int questID;
public int taskID;
public UUID owner = null;
public int questID = -1;
public int taskID = -1;

private DBEntry<IQuest> qCached;

Expand Down

0 comments on commit bd021e7

Please sign in to comment.