diff options
author | BlueWeabo <ilia.iliev2005@gmail.com> | 2024-02-17 00:12:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 23:12:40 +0100 |
commit | 985a6c94cae0cb895a09ef06c85ec7759132a06c (patch) | |
tree | 34beeec33a7dbe00c6791e214eec3ebb0f5ee003 /src/main/java/gregtech/api | |
parent | d827dad0a671b79b1c42915b23d365398fd63733 (diff) | |
download | GT5-Unofficial-985a6c94cae0cb895a09ef06c85ec7759132a06c.tar.gz GT5-Unofficial-985a6c94cae0cb895a09ef06c85ec7759132a06c.tar.bz2 GT5-Unofficial-985a6c94cae0cb895a09ef06c85ec7759132a06c.zip |
Change over wireless teams to use SP teams (#2493)
* Change over wireless teams to use SP teams
* spotless
* null checks
* fix unit test being wrong
* update
* add tab autocomplete
* spotless
* make sure teams are transfered over correctly
* spotless
* do not delete space teams data when two world saves put something into it
* spotless
* go away from a stream
* make wireless networks load later
---------
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/api')
4 files changed, 33 insertions, 46 deletions
diff --git a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java index 47c03743a5..b931549a07 100644 --- a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java +++ b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java @@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.misc.WirelessNetworkManager; +import gregtech.common.misc.spaceprojects.SpaceProjectManager; // If you are adding very late-game content feel free to tap into this interface. // The eventual goal is to bypass laser/dynamo stuff and have energy deposited directly from ultra-endgame @@ -17,37 +18,33 @@ import gregtech.common.misc.WirelessNetworkManager; @Deprecated public interface IGlobalWirelessEnergy { - // User 0 will join user 1 by calling this function. They will share the same energy network. - default void joinUserNetwork(String user_uuid_0, String user_uuid_1) { - WirelessNetworkManager.joinUserNetwork(user_uuid_0, user_uuid_1); - } - - // Adds a user to the energy map if they do not already exist. Otherwise, do nothing. Will also check if the user - // has changed their username and adjust the maps accordingly. This should be called infrequently. Ideally on first + // Adds a user to the energy map if they do not already exist. Otherwise, do + // nothing. Will also check if the user + // has changed their username and adjust the maps accordingly. This should be + // called infrequently. Ideally on first // tick of a machine being placed only. default void strongCheckOrAddUser(EntityPlayer user) { - WirelessNetworkManager.strongCheckOrAddUser( - user.getUniqueID() - .toString(), - user.getDisplayName()); + WirelessNetworkManager.strongCheckOrAddUser(user.getUniqueID()); } default void strongCheckOrAddUser(UUID user_uuid, String user_name) { - WirelessNetworkManager.strongCheckOrAddUser(user_uuid.toString(), user_name); + WirelessNetworkManager.strongCheckOrAddUser(user_uuid); } default void strongCheckOrAddUser(String user_uuid, String user_name) { - WirelessNetworkManager.strongCheckOrAddUser(user_uuid, user_name); + WirelessNetworkManager.strongCheckOrAddUser(UUID.fromString(user_uuid)); } // ------------------------------------------------------------------------------------ - // Add EU to the users global energy. You can enter a negative number to subtract it. + // Add EU to the users global energy. You can enter a negative number to + // subtract it. // If the value goes below 0 it will return false and not perform the operation. - // BigIntegers have much slower operations than longs/ints. You should call these methods + // BigIntegers have much slower operations than longs/ints. You should call + // these methods // as infrequently as possible and bulk store values to add to the global map. default boolean addEUToGlobalEnergyMap(String userUUID, BigInteger EU) { - return WirelessNetworkManager.addEUToGlobalEnergyMap(userUUID, EU); + return WirelessNetworkManager.addEUToGlobalEnergyMap(UUID.fromString(userUUID), EU); } default boolean addEUToGlobalEnergyMap(UUID user_uuid, BigInteger EU) { @@ -73,36 +70,29 @@ public interface IGlobalWirelessEnergy { // ------------------------------------------------------------------------------------ default BigInteger getUserEU(String user_uuid) { - return WirelessNetworkManager.getUserEU(user_uuid); + return WirelessNetworkManager.getUserEU(UUID.fromString(user_uuid)); } - // This overwrites the EU in the network. Only use this if you are absolutely sure you know what you are doing. + // This overwrites the EU in the network. Only use this if you are absolutely + // sure you know what you are doing. default void setUserEU(String user_uuid, BigInteger EU) { - WirelessNetworkManager.setUserEU(user_uuid, EU); + WirelessNetworkManager.setUserEU(UUID.fromString(user_uuid), EU); } default String GetUsernameFromUUID(String uuid) { - return WirelessNetworkManager.getUsernameFromUUID(uuid); + return SpaceProjectManager.getPlayerNameFromUUID(UUID.fromString(uuid)); } default String getUUIDFromUsername(String username) { - return WirelessNetworkManager.getUUIDFromUsername(username); - } - - /** - * - * @param username - * @return - */ - default String getRawUUIDFromUsername(String username) { - return WirelessNetworkManager.getRawUUIDFromUsername(username); + return SpaceProjectManager.getPlayerUUIDFromName(username) + .toString(); } static void clearGlobalEnergyInformationMaps() { WirelessNetworkManager.clearGlobalEnergyInformationMaps(); } - default String processInitialSettings(final IGregTechTileEntity machine) { + default UUID processInitialSettings(final IGregTechTileEntity machine) { return WirelessNetworkManager.processInitialSettings(machine); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java index 4b73210afd..a04f5cd986 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java @@ -5,6 +5,8 @@ import static gregtech.api.enums.GT_Values.V; import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; import static gregtech.common.misc.WirelessNetworkManager.strongCheckOrAddUser; +import java.util.UUID; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; @@ -19,8 +21,7 @@ import gregtech.api.metatileentity.MetaTileEntity; public class GT_MetaTileEntity_Wireless_Dynamo extends GT_MetaTileEntity_Hatch_Dynamo implements IWirelessEnergyHatchInformation { - private String owner_uuid; - private String owner_name; + private UUID owner_uuid; public GT_MetaTileEntity_Wireless_Dynamo(String aName, byte aTier, String[] aDescription, ITexture[][][] aTextures) { @@ -130,11 +131,9 @@ public class GT_MetaTileEntity_Wireless_Dynamo extends GT_MetaTileEntity_Hatch_D if (aTick == 1) { // UUID and username of the owner. - owner_uuid = aBaseMetaTileEntity.getOwnerUuid() - .toString(); - owner_name = aBaseMetaTileEntity.getOwnerName(); + owner_uuid = aBaseMetaTileEntity.getOwnerUuid(); - strongCheckOrAddUser(owner_uuid, owner_name); + strongCheckOrAddUser(owner_uuid); } // Every ticks_between_energy_addition ticks change the energy content of the machine. diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java index 251a9dfcec..bf624eadd7 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java @@ -3,10 +3,10 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.AuthorColen; import static gregtech.api.enums.GT_Values.V; import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; -import static gregtech.common.misc.WirelessNetworkManager.strongCheckOrAddUser; import static java.lang.Long.min; import java.math.BigInteger; +import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -18,6 +18,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IWirelessEnergyHatchInformation; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.common.misc.spaceprojects.SpaceProjectManager; public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_Energy implements IWirelessEnergyHatchInformation { @@ -26,8 +27,7 @@ public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_En .valueOf(2 * V[mTier] * ticks_between_energy_addition); private final long eu_transferred_per_operation_long = eu_transferred_per_operation.longValue(); - private String owner_uuid; - private String owner_name; + private UUID owner_uuid; public GT_MetaTileEntity_Wireless_Hatch(String aName, byte aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); @@ -132,12 +132,10 @@ public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_En if (!aBaseMetaTileEntity.isServerSide()) return; - // UUID and username of the owner. - owner_uuid = aBaseMetaTileEntity.getOwnerUuid() - .toString(); - owner_name = aBaseMetaTileEntity.getOwnerName(); + // UUID of the owner. + owner_uuid = aBaseMetaTileEntity.getOwnerUuid(); - strongCheckOrAddUser(owner_uuid, owner_name); + SpaceProjectManager.checkOrCreateTeam(owner_uuid);; tryFetchingEnergy(); } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java index 8ac908be12..7ffdc4fb60 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java @@ -1066,7 +1066,7 @@ public abstract class Controller<C extends Controller<C, P>, P extends MuTEProce @Override public void setWirelessSupport(boolean canUse) { if (canUse) { - strongCheckOrAddUser(getOwnerUuid(), getOwnerName()); + strongCheckOrAddUser(getOwnerUuid()); } power.setCanUseWireless(canUse, getOwnerUuid()); } |