|
| 1 | +package org.gotti.wurmunlimited.mods.disciomod; |
| 2 | + |
| 3 | +import java.lang.reflect.Field; |
| 4 | +import java.lang.reflect.InvocationHandler; |
| 5 | +import java.lang.reflect.Method; |
| 6 | +import java.util.Properties; |
| 7 | +import java.util.logging.Level; |
| 8 | +import java.util.logging.Logger; |
| 9 | + |
| 10 | +import org.gotti.wurmunlimited.modloader.ReflectionUtil; |
| 11 | +import org.gotti.wurmunlimited.modloader.classhooks.HookManager; |
| 12 | +import org.gotti.wurmunlimited.modloader.interfaces.Configurable; |
| 13 | +import org.gotti.wurmunlimited.modloader.interfaces.WurmMod; |
| 14 | + |
| 15 | +import com.wurmonline.server.Server; |
| 16 | + |
| 17 | +public class DiscIOMod implements WurmMod, Configurable { |
| 18 | + |
| 19 | + private Logger logger = Logger.getLogger(this.getClass().getName()); |
| 20 | + |
| 21 | + @Override |
| 22 | + public void configure(Properties properties) { |
| 23 | + |
| 24 | + logger.log(Level.INFO, "fix disc io problem"); |
| 25 | + |
| 26 | + HookManager.getInstance().registerHook("com.wurmonline.server.zones.Zones", "saveProtectedTiles", "()V", new InvocationHandler() { |
| 27 | + @Override |
| 28 | + public Object invoke(Object object, Method method, Object[] args) throws Throwable { |
| 29 | + Field lastResetTiles = ReflectionUtil.getField(Server.class, "lastResetTiles"); |
| 30 | + ReflectionUtil.setPrivateField(Server.class, lastResetTiles, System.currentTimeMillis()); |
| 31 | + return method.invoke(object, args); |
| 32 | + } |
| 33 | + }); |
| 34 | + } |
| 35 | +} |
0 commit comments