Skip to content

Commit

Permalink
feat: balancing adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
m1919810 committed Sep 6, 2024
1 parent d41afc1 commit 581cb2f
Show file tree
Hide file tree
Showing 61 changed files with 2,771 additions and 822 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.matl114</groupId>
<artifactId>LogiTech</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<defaultGoal>clean package</defaultGoal>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.matl114</groupId>
<artifactId>LogiTech</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<properties>
<maven.compiler.source>16</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.libraries.commons.lang.NotImplementedException;
import me.matl114.logitech.SlimefunItem.AddDepends;
import me.matl114.logitech.SlimefunItem.Cargo.Storages;
import me.matl114.logitech.Utils.*;
import me.matl114.logitech.Utils.UtilClass.StorageClass.StorageType;
import org.bukkit.inventory.ItemStack;
Expand All @@ -16,6 +17,7 @@
import java.lang.reflect.Method;

public class NetworksAdaptQuantumStorage extends StorageType {
int ExceptionTimes=0;
public NetworksAdaptQuantumStorage() {
super();
}
Expand Down Expand Up @@ -48,20 +50,30 @@ public boolean canStorage(SlimefunItem item) {
// return AddDepends.NETWORKSQUANTUMSTORAGE.isInstance(item);
}
public QuantumCache getQuantumCache(ItemMeta meta) {
QuantumCache cache= DataTypeMethods.getCustom(meta, AddDepends.NTWQUANTUMKEY, PersistentQuantumStorageType.TYPE);
if(cache==null){
}
return cache;
try{
QuantumCache cache= DataTypeMethods.getCustom(meta, AddDepends.NTWQUANTUMKEY, PersistentQuantumStorageType.TYPE);
return cache;
}catch (Throwable e){
disableNetworkQuantum(e);
return null;
}
}
public void disableNetworkQuantum(Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_STORAGE, STORAGE TYPE DISABLED");
Debug.logger(e);
ExceptionTimes++;
if(ExceptionTimes>60){
Storages.disableNetworkStorage();
disableStorageType(this);
}
}
public int getStorageMaxSize(QuantumCache cache){
if(cache==null){return 0;}
Method amount=NetWorkQuantumMethod. getLimitMethod(cache);
try{
return (Integer)amount.invoke(cache);
}catch (Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_STORAGE, STORAGE TYPE DISABLED");
Debug.logger(e);
disableStorageType(this);
disableNetworkQuantum(e);
return 0;
}
}
Expand All @@ -82,13 +94,11 @@ public void setStorage(ItemMeta meta, ItemStack content) {

public void setAmount(QuantumCache cache, int amount) {
if(cache==null){return;}
Method set=NetWorkQuantumMethod.getSetAmountMethod(cache);
Method set=NetWorkQuantumMethod.getSetAmountMethod(cache);
try{
set.invoke(cache, amount);
}catch (Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_STORAGE, STORAGE TYPE DISABLED");
Debug.logger(e);
disableStorageType(this);
disableNetworkQuantum(e);
return ;
}
}
Expand All @@ -111,9 +121,7 @@ public int getStorageAmount(QuantumCache cache){
Object res= amount.invoke(cache);
return res instanceof Long r? MathUtils.fromLong(r) : (Integer) res;
}catch (Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_STORAGE, STORAGE TYPE DISABLED");
Debug.logger(e);
disableStorageType(this);
disableNetworkQuantum(e);
return 0;
}
}
Expand All @@ -130,9 +138,7 @@ public ItemStack getStorageContent(QuantumCache cache){
try{
return (ItemStack) getItem.invoke(cache);
}catch (Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_STORAGE, STORAGE TYPE DISABLED");
Debug.logger(e);
disableStorageType(this);
disableNetworkQuantum(e);
return null;
}
}
Expand All @@ -153,9 +159,7 @@ public void onStorageDisplayWrite(ItemMeta meta, int amount) {
set=NetWorkQuantumMethod.getUpdateMetaLore(cache);
set.invoke(cache, meta);
}catch (Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_STORAGE, STORAGE TYPE DISABLED");
Debug.logger(e);
disableStorageType(this);
disableNetworkQuantum(e);
}
}
}
39 changes: 28 additions & 11 deletions src/main/java/me/matl114/logitech/Depends/NetworksQuantumProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.libraries.commons.lang.NotImplementedException;
import me.matl114.logitech.MyAddon;
import me.matl114.logitech.SlimefunItem.AddDepends;
import me.matl114.logitech.SlimefunItem.AddSlimefunItems;
import me.matl114.logitech.SlimefunItem.Cargo.Storages;
import me.matl114.logitech.SlimefunItem.CustomSlimefunItem;
import me.matl114.logitech.Utils.AddUtils;
import me.matl114.logitech.Utils.DataCache;
import me.matl114.logitech.Utils.Debug;
Expand All @@ -23,8 +27,7 @@ public class NetworksQuantumProxy extends NetworksAdaptQuantumStorage implements
public final Map cacheMap ;
{
if(INSTANCE==null){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_PROXY, STORAGE TYPE DISABLED");
disableStorageType(this);
disableNetworkQuantum(new Exception("SlimefunItem INSTANCE NTW_QUANTUN_STORAGE_1 not found!"));
throw new NotImplementedException("NetworksQuantumStorage Instance not found");
}
cacheMap=NetWorkQuantumMethod.getCacheMap(INSTANCE);
Expand All @@ -34,9 +37,18 @@ public boolean isStorage(ItemMeta meta) {
return getQuantumCache(meta)!=null;
}
public QuantumCache getQuantumCache(ItemMeta meta) {
Location loc=getLocation(meta);
if(loc==null) return null;
else return (QuantumCache)cacheMap.get(loc) ;
try{
Location loc=getLocation(meta);
if(loc==null) return null;
else {
Object obj=cacheMap.get(loc);
if(obj==null)return null;
return (QuantumCache)cacheMap.get(loc);
}
}catch (Throwable e){
disableNetworkQuantum(e);
return null;
}
}
public ItemStack getItemStack(Location loc) {
return getStorageContent ((QuantumCache)cacheMap.get(loc) );
Expand All @@ -52,6 +64,15 @@ public Location getLocation(ItemMeta meta){
public void setAmount(Location loc,int amount){
setAmount((QuantumCache)cacheMap.get(loc),amount);
}
public void disableNetworkQuantum(Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_PROXY, STORAGE TYPE DISABLED");
Debug.logger(e);
ExceptionTimes++;
if(ExceptionTimes>60){
Storages.disableNetworkProxy();
disableStorageType(this);
}
}
public void updateLocation(Location loc){
Method method=NetWorkQuantumMethod.getSyncBlock(INSTANCE);
try{
Expand All @@ -60,9 +81,7 @@ public void updateLocation(Location loc){
method.invoke(null,loc,cache);
}
}catch(Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_PROXY, STORAGE TYPE DISABLED");
Debug.logger(e);
disableStorageType(this);
disableNetworkQuantum(e);
return;
}
}
Expand All @@ -76,9 +95,7 @@ public void onStorageAmountWrite(ItemMeta meta, int amount) {
try{
set.invoke(cache, amount);
}catch (Throwable e){
Debug.logger("AN ERROR OCCURED IN NETWORK_QUANTUM_PROXY, STORAGE TYPE DISABLED");
Debug.logger(e);
disableStorageType(this);
disableNetworkQuantum(e);
}
//DataTypeMethods.setCustom(meta, Keys.QUANTUM_STORAGE_INSTANCE, PersistentQuantumStorageType.TYPE,cache);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/me/matl114/logitech/Items/CustomHead.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public enum CustomHead {
HOT_MACHINE("430996b83126b761594885d509cff2da11cda55450c8cf60b28ddacbcf0294a1"),
CHIP_REACTOR("d600f0d2b2ab524b219e0fa808c80b26e7236780681867a0617f73ce3671cd2f"),
LASER("9774928d51298e7d66aee92aa5d33e442bd4e037324463ff5a5440dce9e13f65"),
FIRE_GENERATOR("9343ce58da54c79924a2c9331cfc417fe8ccbbea9be45a7ac85860a6c730")
FIRE_GENERATOR("9343ce58da54c79924a2c9331cfc417fe8ccbbea9be45a7ac85860a6c730"),
BIG_SNAKE("e51d60a0e4d73035963bf66e0b7869ca8e0056657398b3224b83ebd4b90e8292")
;
private ItemStack item;
public ItemStack getItem() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AbstractEffect reigster(){
public boolean onDeathClear(){
return true;
}
public void onDeathEvent(PlayerDeathEvent e) {
public void onDeathEvent(PlayerDeathEvent e,int level) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void tickEffect(Player p,int level) {
}
public void aquireEffect(Player p,int level) {
}
public void onDeathEvent(PlayerDeathEvent e) {
public void onDeathEvent(PlayerDeathEvent e,int level) {
e.setDeathMessage(AddUtils.resolveColor( "%s &6在超新星的烈焰中化为灰烬".formatted(e.getEntity().getName())));
}
};
Expand All @@ -70,7 +70,7 @@ public void tickEffect(Player p,int level) {
public void aquireEffect(Player p,int level) {

}
public void onDeathEvent(PlayerDeathEvent e) {
public void onDeathEvent(PlayerDeathEvent e,int level) {
e.setDeathMessage(AddUtils.resolveColor( "%s &6的身体被核辐射穿成了筛子".formatted(e.getEntity().getName())));
}
};
Expand All @@ -89,8 +89,33 @@ public void removeEffect(Player p, int level) {
public void tickEffect(Player p, int level) {

}
public void onDeathEvent(PlayerDeathEvent e) {
e.setDeathMessage(AddUtils.resolveColor( "%s &6因选错了方向而被系统制裁".formatted(e.getEntity().getName())));
public void onDeathEvent(PlayerDeathEvent e,int level) {
if(level==1){
e.setDeathMessage(AddUtils.resolveColor( "%s &6因选错了方向而被系统制裁".formatted(e.getEntity().getName())));
}else if(level==2){
e.setDeathMessage(AddUtils.resolveColor( "%s &6因尝试学习刷物而被系统制裁".formatted(e.getEntity().getName())));
}
}
};
public static AbstractEffect LASER = new AbstractEffect("LASER") {
@Override
public void aquireEffect(Player p, int level) {

}

@Override
public void removeEffect(Player p, int level) {

}

@Override
public void tickEffect(Player p, int level) {
double d=p.getHealth();
d=Math.min(0,d-0.5*level*level);
p.setHealth(d);
}
public void onDeathEvent(PlayerDeathEvent e,int level) {
e.setDeathMessage(AddUtils.resolveColor( "%s &6被%d级的强力激光融化了".formatted(e.getEntity().getName(),level)));
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import me.matl114.logitech.Schedule.PersistentEffects.CustomEffects;
import me.matl114.logitech.Schedule.PersistentEffects.PlayerEffects;
import me.matl114.logitech.Utils.Debug;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.PlayerDeathEvent;

Expand Down Expand Up @@ -70,7 +72,7 @@ public static void clearEffectsOnDeath(PlayerDeathEvent e) {
for(AbstractEffect effect : effectSet) {
PlayerEffects eff= effects.get(effect);
if(eff!=null&&(!eff.isFinished())){
eff.getType().onDeathEvent(e);
eff.getType().onDeathEvent(e,eff.level);
if(eff.getType().onDeathClear()){
eff.finish();
}
Expand Down Expand Up @@ -133,6 +135,7 @@ public static void addEffect(Player player, PlayerEffects effect, Function<Playe
/**
* 该runnable只能在Schedules的effect线程运行
*/

public static void scheduleEffects(){
HashMap<AbstractEffect,PlayerEffects> effects;

Expand Down
46 changes: 45 additions & 1 deletion src/main/java/me/matl114/logitech/SlimefunItem/AddDepends.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import jdk.jshell.execution.Util;
import me.matl114.logitech.SlimefunItem.Items.MyVanillaItem;
import me.matl114.logitech.SlimefunItem.Machines.AutoMachines.AdvanceRecipeCrafter;
import me.matl114.logitech.SlimefunItem.Machines.ManualMachines.ManualCrafter;
import me.matl114.logitech.SlimefunItem.Machines.WorkBenchs.BugCrafter;
Expand All @@ -21,6 +23,7 @@ public static void setup(SlimefunAddon plugin){
}
public static void registerSlimefunItems(SlimefunAddon plugin){
try{
if(hasInfiniteExpansion)
MOBDATA_MANUAL=new ManualCrafter(AddGroups.MANUAL,AddItem.MOBDATA_MANUAL, BugCrafter.TYPE,
AddSlimefunItems.recipe(null,null,AddItem.BUG,AddItem.BUG,null,null,
null,AddItem.BUG,AddItem.LCRAFT,AddItem.LCRAFT,AddItem.BUG,null,
Expand All @@ -34,7 +37,7 @@ public static void registerSlimefunItems(SlimefunAddon plugin){
e.printStackTrace();
}
try{

if(hasInfiniteExpansion)
INFINITY_MANUAL=new ManualCrafter(AddGroups.MANUAL,AddItem.INFINITY_MANUAL,BugCrafter.TYPE,
AddSlimefunItems.recipe(null,null,null,null,null,null,
AddItem.ABSTRACT_INGOT,"REINFORCED_PLATE","REINFORCED_PLATE","REINFORCED_PLATE","REINFORCED_PLATE",AddItem.ABSTRACT_INGOT,
Expand All @@ -48,6 +51,7 @@ public static void registerSlimefunItems(SlimefunAddon plugin){
e.printStackTrace();
}
try{
if(hasNetwork)
NTWWORKBENCH_MANUAL=new ManualCrafter(AddGroups.MANUAL,AddItem.NTWWORKBENCH_MANUAL,BugCrafter.TYPE,
AddSlimefunItems.recipe(null,null,null,null,null,null,
null,"NTW_BRIDGE","ADVANCED_CIRCUIT_BOARD","ADVANCED_CIRCUIT_BOARD","NTW_BRIDGE",null,
Expand All @@ -62,6 +66,7 @@ public static void registerSlimefunItems(SlimefunAddon plugin){
e.printStackTrace();
}
try{
if(hasInfiniteExpansion)
INFINITY_AUTOCRAFT =new AdvanceRecipeCrafter(AddGroups.BASIC, AddItem.INFINITY_AUTOCRAFT,BugCrafter.TYPE,
AddSlimefunItems.recipe(AddItem.LFIELD,"INFINITE_INGOT",AddItem.DIMENSIONAL_SHARD,AddItem.DIMENSIONAL_SHARD,"INFINITE_INGOT",AddItem.LFIELD,
"INFINITE_INGOT",AddItem.LCRAFT,"2VOID_INGOT","2VOID_INGOT",AddItem.LMOTOR,"INFINITE_INGOT",
Expand All @@ -75,6 +80,44 @@ public static void registerSlimefunItems(SlimefunAddon plugin){
Debug.logger("AN ERROR OCCURED WHILE REGISTERING ITEM: INFINITY_AUTOCRAFT,ITEM DISABLED");
e.printStackTrace();
}
try {
if(hasNetwork)
NTW_STORAGE_DISPLAY=new MyVanillaItem(AddGroups.SINGULARITY,SlimefunItem.getById("NTW_QUANTUM_STORAGE_8").getItem().clone(),"NTW_QUANTUM_STORAGE_DISPLAY",RecipeType.ENHANCED_CRAFTING_TABLE,
AddSlimefunItems.recipe(AddItem.STORAGE_SINGULARITY,"NTW_QUANTUM_STORAGE_1",AddItem.STORAGE_SINGULARITY,
"NTW_QUANTUM_STORAGE_1",AddItem.IOPORT,"NTW_QUANTUM_STORAGE_1",
AddItem.STORAGE_SINGULARITY,"NTW_QUANTUM_STORAGE_1",AddItem.STORAGE_SINGULARITY) )
.setDisplayRecipes(
Utils.list(
AddUtils.getInfoShow("&f机制 - &c终极合成",
"&c特性 ",
"&7终极合成是本附属某些终极机器中的机制",
"&c具体说明请看\"版本与说明\"分类中的信息",
"&7直白了说是让物品存储中的物品直接参与合成/进程",
"&7从而打破槽位限制",
"&7该物品是终极机器支持的物品之一",
"&a建议:不推荐直接将量子存储放入终极机器,不方便且会有更高卡顿!"),
null,
AddUtils.getInfoShow("&7机制 -&c 物品存储",
"&7本物品可以存储某种物品",
"&7本物品的最大存储量为2147483647",
"&7当该物品被放入终极机器的槽位中时,",
"&7可以代理其内部存储的物品&e直接参与合成!",
"&7产出的物品也可以&e直接进入内部存储的物品中!",
"&e本物品是网络附属里的支持物品,直接置于地上即可使用"),null,
AddUtils.getInfoShow("&7机制 -&c 报错",
"&e如果网络版本不兼容或使用了错误的测试版,会造成报错",
"&7如果使用量子存储进行合成时,出现合成不成功的情况",
"&7很可能这是数据损坏的存储或者错误版本导致的存储不兼容",
"&e请立刻将其移出槽位",
"&7并判断是存储数据损坏问题还是网络版本问题",
"&7若累计报错达到一定数目,将会禁用该兼容"),null
)
).register();

}catch (Throwable e){
Debug.logger("AN ERROR OCCURED WHILE REGISTERING ITEM: NTW_STORAGE_DISPLAY,ITEM DISABLED");
e.printStackTrace();
}
}
public static boolean hasInfiniteExpansion=false;
public static boolean hasNetwork=false;
Expand All @@ -90,6 +133,7 @@ public static void registerSlimefunItems(SlimefunAddon plugin){
public static SlimefunItem INFINITY_MANUAL;
public static SlimefunItem NTWWORKBENCH_MANUAL;
public static SlimefunItem INFINITY_AUTOCRAFT;
public static MyVanillaItem NTW_STORAGE_DISPLAY;
public static Class NETWORKSQUANTUMSTORAGE;
public static NamespacedKey NTWQUANTUMKEY;
}
Loading

0 comments on commit 581cb2f

Please sign in to comment.