[factions-banking] Huge amount of unrelated fixes with null checks + a new faction skill in the works (beacon effect). Fixed bad listener code in flight code!
Some checks failed
build / build (21) (push) Has been cancelled
Some checks failed
build / build (21) (push) Has been cancelled
This commit is contained in:
parent
7efeb689cb
commit
c8e379e564
@ -10,10 +10,12 @@
|
|||||||
package jesse.keeblarcraft.AttributeMgr;
|
package jesse.keeblarcraft.AttributeMgr;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import jesse.keeblarcraft.Keeblarcraft;
|
import jesse.keeblarcraft.Keeblarcraft;
|
||||||
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.AbstractNode;
|
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.AbstractNode;
|
||||||
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.AttributeMetalJacket;
|
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.AttributeMetalJacket;
|
||||||
|
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.FactionNodes.FactionBeacon;
|
||||||
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.FactionNodes.FactionFlight;
|
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.FactionNodes.FactionFlight;
|
||||||
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
||||||
|
|
||||||
@ -68,6 +70,19 @@ public class AttributeMgr {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static String ApplyAttribute(String uuid, String attributeName) {
|
public static String ApplyAttribute(String uuid, String attributeName) {
|
||||||
String msg = "";
|
String msg = "";
|
||||||
|
// System.out.println("ApplyAttribute debug. UUID - NAME: " + uuid + " - " + attributeName);
|
||||||
|
|
||||||
|
// Set<String> keys = attributes.keySet();
|
||||||
|
// for (String key : keys) {
|
||||||
|
// System.out.println("ATTRI: " + key);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// System.out.println("ACTIVE TREES: ");
|
||||||
|
// Set<String> names = activeTrees.keySet();
|
||||||
|
// for (String name : names) {
|
||||||
|
// System.out.println("N: " + name);
|
||||||
|
// }
|
||||||
|
|
||||||
if (attributes.containsKey(attributeName)) {
|
if (attributes.containsKey(attributeName)) {
|
||||||
AttributeTree playerTree = activeTrees.get(uuid);
|
AttributeTree playerTree = activeTrees.get(uuid);
|
||||||
AbstractNode node = null;
|
AbstractNode node = null;
|
||||||
@ -77,6 +92,13 @@ public class AttributeMgr {
|
|||||||
Keeblarcraft.LOGGER.error("Could not successfully apply attribute. String of attribute name could not be successfully cast to actual java object");
|
Keeblarcraft.LOGGER.error("Could not successfully apply attribute. String of attribute name could not be successfully cast to actual java object");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// System.out.println("Is player tree null: " + (playerTree == null ? "YES" : "NO"));
|
||||||
|
// System.out.println("Is player node null: " + (node == null ? "YES" : "NO"));
|
||||||
|
|
||||||
|
// if (playerTree != null) {
|
||||||
|
// System.out.println("Does player have skill: " + (playerTree.ContainsAttribute(attributeName) ? "YES" : "NO"));
|
||||||
|
// }
|
||||||
|
|
||||||
// Ensure player tree isn't null; node isn't null; and the player doesn't already have this attribute
|
// Ensure player tree isn't null; node isn't null; and the player doesn't already have this attribute
|
||||||
if (playerTree != null && node != null && !playerTree.ContainsAttribute(attributeName)) {
|
if (playerTree != null && node != null && !playerTree.ContainsAttribute(attributeName)) {
|
||||||
///////////
|
///////////
|
||||||
@ -125,6 +147,7 @@ public class AttributeMgr {
|
|||||||
/// hint: make it an API for other modders to add to
|
/// hint: make it an API for other modders to add to
|
||||||
|
|
||||||
RegisterAttributeClass(AttributeMetalJacket.class);
|
RegisterAttributeClass(AttributeMetalJacket.class);
|
||||||
|
RegisterAttributeClass(FactionBeacon.class);
|
||||||
RegisterAttributeClass(FactionFlight.class);
|
RegisterAttributeClass(FactionFlight.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@ package jesse.keeblarcraft.AttributeMgr.AttributeNodes;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
|
|
||||||
abstract public class AbstractNode {
|
abstract public class AbstractNode {
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
/// @fn GetNodeTitle
|
/// @fn GetNodeTitle
|
||||||
@ -50,5 +47,5 @@ abstract public class AbstractNode {
|
|||||||
/// @brief If your node has responsive callbacks; then this is the area
|
/// @brief If your node has responsive callbacks; then this is the area
|
||||||
/// you will register your callbacks for everything
|
/// you will register your callbacks for everything
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
public abstract void RegisterCallbacks(ServerPlayerEntity player, ServerWorld world);
|
public abstract void RegisterCallbacks();
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,6 @@ public final class AttributeMetalJacket extends AbstractNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void RegisterCallbacks(ServerPlayerEntity player, ServerWorld world) {
|
public void RegisterCallbacks() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package jesse.keeblarcraft.AttributeMgr.AttributeNodes.FactionNodes;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.AbstractNode;
|
||||||
|
import jesse.keeblarcraft.FactionMgr.Callbacks.PlayerInBaseCallback;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
|
||||||
|
public class FactionBeacon extends AbstractNode {
|
||||||
|
private int beaconStrength = 1; // Increases with faction power; 1 is default
|
||||||
|
private float absorptionAmnt = 0.2f * beaconStrength;
|
||||||
|
@Override
|
||||||
|
public String GetNodeTitle() {
|
||||||
|
return "faction_beacon";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String GetNodeDescription() {
|
||||||
|
return "This is a great unlockable for any faction to have and is leveled up with higher faction power. Gives beacon-like abilities + more!";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, List<String>> GetDetails() {
|
||||||
|
HashMap<String, List<String>> ret = new HashMap<String, List<String>>();
|
||||||
|
ret.put("Faction Beacon", List.of("Grants a ton of beacon-like effects on faction members inside the radius of the faction block"));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyEffects(ServerPlayerEntity player) {
|
||||||
|
// player.setAbsorptionAmount(absorptionAmnt);
|
||||||
|
StatusEffectInstance sei = new StatusEffectInstance(StatusEffects.REGENERATION, 1000, 1, true, true, true);
|
||||||
|
player.addStatusEffect(sei);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void RegisterCallbacks() {
|
||||||
|
System.out.println("REGISTER CALLBACKS FOR FACTION BEACON CALLED");
|
||||||
|
PlayerInBaseCallback.EVENT.register((player, world) -> {
|
||||||
|
// Make sure player can fly while inside the border. We don't ever want to run this more than once!
|
||||||
|
// player.sendMessage(Text.of("Applying effects"));
|
||||||
|
ApplyEffects((ServerPlayerEntity) player);
|
||||||
|
return ActionResult.SUCCESS;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,6 @@ import jesse.keeblarcraft.FactionMgr.Callbacks.PlayerExitedBaseCallback;
|
|||||||
import jesse.keeblarcraft.FactionMgr.Callbacks.PlayerInBaseCallback;
|
import jesse.keeblarcraft.FactionMgr.Callbacks.PlayerInBaseCallback;
|
||||||
import net.minecraft.entity.player.PlayerAbilities;
|
import net.minecraft.entity.player.PlayerAbilities;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ public class FactionFlight extends AbstractNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void RegisterCallbacks(ServerPlayerEntity playerObj, ServerWorld worldObj) {
|
public void RegisterCallbacks() {
|
||||||
PlayerEnteredBaseCallback.EVENT.register((player, world) -> {
|
PlayerEnteredBaseCallback.EVENT.register((player, world) -> {
|
||||||
player.sendMessage(Text.of("Faction flight enabled"));
|
player.sendMessage(Text.of("Faction flight enabled"));
|
||||||
canFly = true;
|
canFly = true;
|
||||||
@ -86,7 +85,7 @@ public class FactionFlight extends AbstractNode {
|
|||||||
|
|
||||||
// Toggle flight
|
// Toggle flight
|
||||||
TurnOnFlight(serverPlayer);
|
TurnOnFlight(serverPlayer);
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.PASS;
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerInBaseCallback.EVENT.register((player, world) -> {
|
PlayerInBaseCallback.EVENT.register((player, world) -> {
|
||||||
@ -98,7 +97,7 @@ public class FactionFlight extends AbstractNode {
|
|||||||
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
|
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
|
||||||
TurnOnFlight(serverPlayer);
|
TurnOnFlight(serverPlayer);
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.PASS;
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerCommandFlightCallback.EVENT.register((player, world) -> {
|
PlayerCommandFlightCallback.EVENT.register((player, world) -> {
|
||||||
@ -122,7 +121,7 @@ public class FactionFlight extends AbstractNode {
|
|||||||
// Means player is not in fly-zone
|
// Means player is not in fly-zone
|
||||||
serverPlayer.sendMessage(Text.of("You can only fly within the bounds of your faction base!"));
|
serverPlayer.sendMessage(Text.of("You can only fly within the bounds of your faction base!"));
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.PASS;
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerExitedBaseCallback.EVENT.register((player, world) -> {
|
PlayerExitedBaseCallback.EVENT.register((player, world) -> {
|
||||||
@ -142,7 +141,7 @@ public class FactionFlight extends AbstractNode {
|
|||||||
}
|
}
|
||||||
}, leaveTimerMs);
|
}, leaveTimerMs);
|
||||||
|
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.PASS;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import jesse.keeblarcraft.Keeblarcraft;
|
|||||||
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.AbstractNode;
|
import jesse.keeblarcraft.AttributeMgr.AttributeNodes.AbstractNode;
|
||||||
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
|
|
||||||
public class AttributeTree {
|
public class AttributeTree {
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ public class AttributeTree {
|
|||||||
/// @brief This is an individual node that goes within the larger
|
/// @brief This is an individual node that goes within the larger
|
||||||
/// PlayerTree class object
|
/// PlayerTree class object
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
private class TreeNode {
|
public class TreeNode {
|
||||||
public TreeNode(AbstractNode node, Integer maxLevel, List<String> parents, List<String> children) {
|
public TreeNode(AbstractNode node, Integer maxLevel, List<String> parents, List<String> children) {
|
||||||
thisNode = node;
|
thisNode = node;
|
||||||
parentNodes = parents;
|
parentNodes = parents;
|
||||||
@ -42,15 +41,15 @@ public class AttributeTree {
|
|||||||
currentNodeLevel = 1;
|
currentNodeLevel = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractNode thisNode;
|
public AbstractNode thisNode;
|
||||||
Integer currentNodeLevel;
|
public Integer currentNodeLevel;
|
||||||
Integer maxNodeLevel;
|
public Integer maxNodeLevel;
|
||||||
|
|
||||||
// Store the names of the parent and children nodes; this lets a node have any number of parents and children
|
// Store the names of the parent and children nodes; this lets a node have any number of parents and children
|
||||||
// NOTE TO DEVELOPERS: Be aware! The more nodes the harrier the tree will look in the GUI!!! Always test your
|
// NOTE TO DEVELOPERS: Be aware! The more nodes the harrier the tree will look in the GUI!!! Always test your
|
||||||
// code before just adding stuff willy-nilly!
|
// code before just adding stuff willy-nilly!
|
||||||
List<String> parentNodes;
|
public List<String> parentNodes;
|
||||||
List<String> childrenNodes;
|
public List<String> childrenNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@ -61,10 +60,10 @@ public class AttributeTree {
|
|||||||
/// stored inside the AttributeMgr class
|
/// stored inside the AttributeMgr class
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
private class PlayerTree {
|
private class PlayerTree {
|
||||||
String uuid;
|
public String uuid;
|
||||||
// Key = name of AbstractNode
|
// Key = name of AbstractNode
|
||||||
// Val = The attribute itself
|
// Val = The attribute itself
|
||||||
HashMap<String, TreeNode> tree = new HashMap<String, TreeNode>();
|
public HashMap<String, TreeNode> tree = new HashMap<String, TreeNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@ -94,7 +93,7 @@ public class AttributeTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void RegisterCallbacks(ServerPlayerEntity player, ServerWorld world) {
|
public void RegisterCallbacks() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +111,7 @@ public class AttributeTree {
|
|||||||
// the callback registration process has already happened
|
// the callback registration process has already happened
|
||||||
if (tree.getValue().thisNode == null) {
|
if (tree.getValue().thisNode == null) {
|
||||||
System.out.println("REGISTERACTIVECALLBACKS - NULL NODE");
|
System.out.println("REGISTERACTIVECALLBACKS - NULL NODE");
|
||||||
tree.getValue().thisNode.RegisterCallbacks(player, player.getServerWorld());
|
tree.getValue().thisNode.RegisterCallbacks();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("REGISTERACTIVECALLBACKS - NOT NULL NODE");
|
System.out.println("REGISTERACTIVECALLBACKS - NOT NULL NODE");
|
||||||
}
|
}
|
||||||
@ -172,9 +171,11 @@ public class AttributeTree {
|
|||||||
playerAttributeTree.tree.put(newNode.GetNodeTitle(), new TreeNode(newNode, maxNodeLevel, parents, children));
|
playerAttributeTree.tree.put(newNode.GetNodeTitle(), new TreeNode(newNode, maxNodeLevel, parents, children));
|
||||||
|
|
||||||
// if the new nodes level is not 0 we need to manually register the callbacks
|
// if the new nodes level is not 0 we need to manually register the callbacks
|
||||||
|
System.out.println("Node title: " + newNode.GetNodeTitle() + " has power level " +
|
||||||
|
playerAttributeTree.tree.get(newNode.GetNodeTitle()).currentNodeLevel);
|
||||||
if (playerAttributeTree.tree.get(newNode.GetNodeTitle()).currentNodeLevel != 0) {
|
if (playerAttributeTree.tree.get(newNode.GetNodeTitle()).currentNodeLevel != 0) {
|
||||||
System.out.println("Registering new callback for new node");
|
System.out.println("Registering new callback for new node");
|
||||||
playerAttributeTree.tree.get(newNode.GetNodeTitle()).thisNode.RegisterCallbacks(player, player.getServerWorld());
|
playerAttributeTree.tree.get(newNode.GetNodeTitle()).thisNode.RegisterCallbacks();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Some fancy error handling for console log
|
// Some fancy error handling for console log
|
||||||
@ -323,6 +324,7 @@ public class AttributeTree {
|
|||||||
/// @brief Flashes the config to the disk
|
/// @brief Flashes the config to the disk
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
public void FlashConfig() {
|
public void FlashConfig() {
|
||||||
config.WriteToJsonFile("attributes/" + playerAttributeTree.uuid + ".json", playerAttributeTree);
|
/// TODO: This is broken because of a 'java.util.Option#value it cannot write. Idk, fix soon'
|
||||||
|
// config.WriteToJsonFile("attributes/" + playerAttributeTree.uuid + ".json", playerAttributeTree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,7 @@ public class AttributeCommands {
|
|||||||
|
|
||||||
public int ApplyAttribute(ServerPlayerEntity targetPlayer, String attributeName, CommandContext<ServerCommandSource> context) {
|
public int ApplyAttribute(ServerPlayerEntity targetPlayer, String attributeName, CommandContext<ServerCommandSource> context) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
System.out.println("Applying attribute");
|
|
||||||
if (context.getSource().isExecutedByPlayer()) {
|
if (context.getSource().isExecutedByPlayer()) {
|
||||||
System.out.println("Executed by player");
|
|
||||||
String result = AttributeMgr.ApplyAttribute(targetPlayer.getUuidAsString(), attributeName);
|
String result = AttributeMgr.ApplyAttribute(targetPlayer.getUuidAsString(), attributeName);
|
||||||
Keeblarcraft.LOGGER.info("[ApplyAttribute] -> " + result);
|
Keeblarcraft.LOGGER.info("[ApplyAttribute] -> " + result);
|
||||||
context.getSource().getPlayer().sendMessage(Text.of(result));
|
context.getSource().getPlayer().sendMessage(Text.of(result));
|
||||||
|
@ -15,6 +15,7 @@ import java.io.FileWriter;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
@ -46,6 +47,7 @@ public class ConfigManager {
|
|||||||
File file = null;
|
File file = null;
|
||||||
System.out.println("Get file called for " + GLOBAL_CONFIG + confFile);
|
System.out.println("Get file called for " + GLOBAL_CONFIG + confFile);
|
||||||
try {
|
try {
|
||||||
|
System.out.println("GetFile Cur Dir: " + Paths.get("").toAbsolutePath().toString());
|
||||||
file = new File(GLOBAL_CONFIG + confFile);
|
file = new File(GLOBAL_CONFIG + confFile);
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
return file;
|
return file;
|
||||||
@ -69,6 +71,8 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("PathOfFile: " + pathToFile);
|
||||||
return pathToFile;
|
return pathToFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +149,7 @@ public class ConfigManager {
|
|||||||
/// @brief Writes NbtList data to disk
|
/// @brief Writes NbtList data to disk
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
public void WriteNbtListToFile(String fileName, String key, NbtList data) {
|
public void WriteNbtListToFile(String fileName, String key, NbtList data) {
|
||||||
fileName = "config/keeblarcraft/" + fileName;
|
// fileName = "config/keeblarcraft/" + fileName;
|
||||||
|
|
||||||
File file = GetFile(fileName);
|
File file = GetFile(fileName);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -176,7 +180,7 @@ public class ConfigManager {
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
public HashMap<String, NbtList> ReadAllNbtListFromDirectory(String dir, int listType) {
|
public HashMap<String, NbtList> ReadAllNbtListFromDirectory(String dir, int listType) {
|
||||||
HashMap<String, NbtList> list = new HashMap<String, NbtList>();
|
HashMap<String, NbtList> list = new HashMap<String, NbtList>();
|
||||||
dir = "config/keeblarcraft/" + dir;
|
// dir = "config/keeblarcraft/" + dir;
|
||||||
|
|
||||||
File directory = GetFile(dir);
|
File directory = GetFile(dir);
|
||||||
|
|
||||||
@ -275,6 +279,7 @@ public class ConfigManager {
|
|||||||
writer.close();
|
writer.close();
|
||||||
} catch (JsonIOException | IOException e) {
|
} catch (JsonIOException | IOException e) {
|
||||||
Keeblarcraft.LOGGER.error("Could not successfully write to json file ["+fileName+"]");
|
Keeblarcraft.LOGGER.error("Could not successfully write to json file ["+fileName+"]");
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,6 +296,7 @@ public class ConfigManager {
|
|||||||
File file = GetFile(fileName);
|
File file = GetFile(fileName);
|
||||||
ret = FileUtils.readFileToString(file, "UTF-8");
|
ret = FileUtils.readFileToString(file, "UTF-8");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
System.out.println("Caught an exception in retrieving JSON Object from file " + fileName);
|
System.out.println("Caught an exception in retrieving JSON Object from file " + fileName);
|
||||||
// throw new JsonSyntaxException("");
|
// throw new JsonSyntaxException("");
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jesse.keeblarcraft.Utils.DirectionalVec;
|
import jesse.keeblarcraft.Utils.DirectionalVec;
|
||||||
import jesse.keeblarcraft.Utils.CustomExceptions.FILE_WRITE_EXCEPTION;
|
|
||||||
|
|
||||||
public class GeneralConfig {
|
public class GeneralConfig {
|
||||||
private static GeneralConfig static_inst;
|
private static GeneralConfig static_inst;
|
||||||
@ -118,6 +117,7 @@ public class GeneralConfig {
|
|||||||
/// @return True if player is new, false if not
|
/// @return True if player is new, false if not
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
public Boolean IsNewPlayer(String uuid) {
|
public Boolean IsNewPlayer(String uuid) {
|
||||||
|
System.out.println("Is config null? " + (config == null ? "YES" : "NO"));
|
||||||
System.out.println("IsNewPlayer called. List has: " + config.playerList);
|
System.out.println("IsNewPlayer called. List has: " + config.playerList);
|
||||||
Boolean isNew = !config.playerList.contains(uuid);
|
Boolean isNew = !config.playerList.contains(uuid);
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ public class SQLConfig {
|
|||||||
// The case is converted to upper case automatically to be case insensitive
|
// The case is converted to upper case automatically to be case insensitive
|
||||||
public Boolean DoesTableExist(String name) {
|
public Boolean DoesTableExist(String name) {
|
||||||
boolean tableExists = false;
|
boolean tableExists = false;
|
||||||
|
if (conn != null) {
|
||||||
try (ResultSet rs = conn.getMetaData().getTables(null, null, name, null)) {
|
try (ResultSet rs = conn.getMetaData().getTables(null, null, name, null)) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String tName = rs.getString("TABLE_NAME");
|
String tName = rs.getString("TABLE_NAME");
|
||||||
@ -125,6 +126,7 @@ public class SQLConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {}
|
} catch (SQLException e) {}
|
||||||
|
}
|
||||||
return tableExists;
|
return tableExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,7 @@ public class SQLConfig {
|
|||||||
public Boolean CreateTable(String tableName, Pair<String, VALID_SQL_TYPE>... columnPairs) {
|
public Boolean CreateTable(String tableName, Pair<String, VALID_SQL_TYPE>... columnPairs) {
|
||||||
Boolean success = false;
|
Boolean success = false;
|
||||||
|
|
||||||
if (!DoesTableExist(tableName.toUpperCase())) {
|
if (conn != null && !DoesTableExist(tableName.toUpperCase())) {
|
||||||
String sqlCommand = "CREATE TABLE " + tableName.toUpperCase() + "(";
|
String sqlCommand = "CREATE TABLE " + tableName.toUpperCase() + "(";
|
||||||
for (Pair<String, VALID_SQL_TYPE> colPair : columnPairs) {
|
for (Pair<String, VALID_SQL_TYPE> colPair : columnPairs) {
|
||||||
sqlCommand = sqlCommand + " " + colPair.GetKey() + " " + SQLTypeSupport.GetSqlStrForType(colPair.GetValue()) + ",";
|
sqlCommand = sqlCommand + " " + colPair.GetKey() + " " + SQLTypeSupport.GetSqlStrForType(colPair.GetValue()) + ",";
|
||||||
|
@ -37,6 +37,7 @@ public class FactionBlockEntity extends BlockEntity implements ExtendedScreenHan
|
|||||||
private static int factionPower = 0;
|
private static int factionPower = 0;
|
||||||
Boolean stopMobSpawn = true;
|
Boolean stopMobSpawn = true;
|
||||||
Boolean hasBuildFlight = true;
|
Boolean hasBuildFlight = true;
|
||||||
|
Boolean hasSuperBeacon = true;
|
||||||
private ArrayList<String> playersInRadius = new ArrayList<>();
|
private ArrayList<String> playersInRadius = new ArrayList<>();
|
||||||
|
|
||||||
protected final PropertyDelegate propertyDelegate;
|
protected final PropertyDelegate propertyDelegate;
|
||||||
@ -142,6 +143,11 @@ public class FactionBlockEntity extends BlockEntity implements ExtendedScreenHan
|
|||||||
AttributeMgr.ApplyAttribute(player.getUuidAsString(), "faction_flight");
|
AttributeMgr.ApplyAttribute(player.getUuidAsString(), "faction_flight");
|
||||||
ActionResult result = PlayerInBaseCallback.EVENT.invoker().interact(player, world);
|
ActionResult result = PlayerInBaseCallback.EVENT.invoker().interact(player, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasSuperBeacon) {
|
||||||
|
AttributeMgr.ApplyAttribute(player.getUuidAsString(), "faction_beacon");
|
||||||
|
// ActionResult result = PlayerInBaseCallback.EVENT.invoker().interact(player, world);
|
||||||
|
}
|
||||||
} else if (!isPlayerInFactionRadius && playersInRadius.contains(player.getUuidAsString())) {
|
} else if (!isPlayerInFactionRadius && playersInRadius.contains(player.getUuidAsString())) {
|
||||||
playersInRadius.remove(player.getUuidAsString());
|
playersInRadius.remove(player.getUuidAsString());
|
||||||
ActionResult result = PlayerExitedBaseCallback.EVENT.invoker().interact(player, world);
|
ActionResult result = PlayerExitedBaseCallback.EVENT.invoker().interact(player, world);
|
||||||
|
@ -38,13 +38,14 @@ public class PlayerJoinListener {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
cachedPlayerConfig = config.GetJsonObjectFromFile(CACHED_PLAYER_LOGIN_CONFIG, CachedUUIDConfig.class);
|
cachedPlayerConfig = config.GetJsonObjectFromFile(CACHED_PLAYER_LOGIN_CONFIG, CachedUUIDConfig.class);
|
||||||
existingFile = true;
|
existingFile = cachedPlayerConfig != null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// intentionally empty
|
// intentionally empty
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!existingFile) {
|
if (!existingFile) {
|
||||||
try {
|
try {
|
||||||
|
cachedPlayerConfig = new CachedUUIDConfig();
|
||||||
config.CreateFile(CACHED_PLAYER_LOGIN_CONFIG);
|
config.CreateFile(CACHED_PLAYER_LOGIN_CONFIG);
|
||||||
FlashCachedConfig();
|
FlashCachedConfig();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -16,7 +16,6 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import jesse.keeblarcraft.Keeblarcraft;
|
import jesse.keeblarcraft.Keeblarcraft;
|
||||||
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
|
||||||
import jesse.keeblarcraft.ChatStuff.ChatMsg;
|
|
||||||
import jesse.keeblarcraft.Utils.CustomExceptions.SETUP_FAILED_EXCEPTION;
|
import jesse.keeblarcraft.Utils.CustomExceptions.SETUP_FAILED_EXCEPTION;
|
||||||
|
|
||||||
// Singleton class is designed to help the mod set itself up and create all the important things. It does two things:
|
// Singleton class is designed to help the mod set itself up and create all the important things. It does two things:
|
||||||
@ -49,24 +48,23 @@ public final class Setup {
|
|||||||
|
|
||||||
// First time setup variables
|
// First time setup variables
|
||||||
private static final List<String> DIRECTORY_LIST = new ArrayList<String>() {{
|
private static final List<String> DIRECTORY_LIST = new ArrayList<String>() {{
|
||||||
add(GLOBAL_CONFIG); // inside config dir
|
add("notes"); // Expect 1 file per player!
|
||||||
add(GLOBAL_CONFIG + "notes"); // Expect 1 file per player!
|
add("factions"); // Expect 1 file per faction!
|
||||||
add(GLOBAL_CONFIG + "factions"); // Expect 1 file per faction!
|
add("story"); // Expect 1 file per story chapter!
|
||||||
add(GLOBAL_CONFIG + "story"); // Expect 1 file per story chapter!
|
add("commands"); // Expect 1 file per command that's configurable!
|
||||||
add(GLOBAL_CONFIG + "commands"); // Expect 1 file per command that's configurable!
|
add("events"); // Expect 1 file per event that is configurable!
|
||||||
add(GLOBAL_CONFIG + "events"); // Expect 1 file per event that is configurable!
|
add("bank");
|
||||||
add(GLOBAL_CONFIG + "bank");
|
add("attributes");
|
||||||
add(GLOBAL_CONFIG + "attributes");
|
add("misc");
|
||||||
add(GLOBAL_CONFIG + "misc");
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
// These will be top-level config files above the directories this mod creates
|
// These will be top-level config files above the directories this mod creates
|
||||||
private static final List<String> FILE_LIST = new ArrayList<String>() {{
|
private static final List<String> FILE_LIST = new ArrayList<String>() {{
|
||||||
add(GLOBAL_CONFIG + "story/general_story_config.json"); // Big config file, determines when players can do certain things at different story levels
|
add("story/general_story_config.json"); // Big config file, determines when players can do certain things at different story levels
|
||||||
add(GLOBAL_CONFIG + "factions/general_factions_config.json"); // General configuration file for factions stuff
|
add("factions/general_factions_config.json"); // General configuration file for factions stuff
|
||||||
add(GLOBAL_CONFIG + "events/general_event_config.json"); // General configuration file for story events!
|
add("events/general_event_config.json"); // General configuration file for story events!
|
||||||
add(GLOBAL_CONFIG + "general.json"); // The super general configuration file! (May be removed)
|
add("general.json"); // The super general configuration file! (May be removed)
|
||||||
add(GLOBAL_CONFIG + "attributes/general_attribute_config.json");
|
add("attributes/general_attribute_config.json");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
// RunChecks()
|
// RunChecks()
|
||||||
|
Loading…
Reference in New Issue
Block a user