Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add agatus proxy #323

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.manolo8.darkbot.core.BotInstaller;
import com.github.manolo8.darkbot.core.itf.Manager;
import com.github.manolo8.darkbot.core.itf.Updatable;
import com.github.manolo8.darkbot.core.objects.facades.AgatusEventProxy;
import com.github.manolo8.darkbot.core.objects.facades.AssemblyMediator;
import com.github.manolo8.darkbot.core.objects.facades.AstralGateProxy;
import com.github.manolo8.darkbot.core.objects.facades.BoosterProxy;
Expand All @@ -18,6 +19,7 @@
import com.github.manolo8.darkbot.core.objects.facades.GauntletPlutusProxy;
import com.github.manolo8.darkbot.core.objects.facades.HighlightProxy;
import com.github.manolo8.darkbot.core.objects.facades.LogMediator;
import com.github.manolo8.darkbot.core.objects.facades.DefaultNpcEventProxy;
import com.github.manolo8.darkbot.core.objects.facades.NpcEventProxy;
import com.github.manolo8.darkbot.core.objects.facades.SettingsProxy;
import com.github.manolo8.darkbot.core.objects.facades.SlotBarsProxy;
Expand Down Expand Up @@ -55,8 +57,9 @@ public class FacadeManager implements Manager, eu.darkbot.api.API.Singleton {
public final HighlightProxy highlight;
public final SpaceMapWindowProxy spaceMapWindowProxy;
public final GauntletPlutusProxy plutus;
public final NpcEventProxy npcEventProxy;
public final DefaultNpcEventProxy npcEventProxy;
public final WorldBossOverviewProxy worldBossOverview;
public final DefaultNpcEventProxy agatusEvent;
public final Updatable group;
public final Updatable groupMediator;

Expand All @@ -80,6 +83,7 @@ public FacadeManager(PluginAPI pluginApi) {
this.plutus = registerProxy("plutus", GauntletPlutusProxy.class);
this.npcEventProxy = registerProxy("npc_event", NpcEventProxy.class);
this.worldBossOverview = registerProxy("worldBoss_overview", WorldBossOverviewProxy.class);
this.agatusEvent = registerProxy("agatus_event", AgatusEventProxy.class);
this.group = registerProxy("GroupProxy", Updatable.NoOp.class);
this.groupMediator = registerMediator("GroupSystemMediator", Updatable.NoOp.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.github.manolo8.darkbot.core.objects.facades;

import eu.darkbot.api.managers.AgatusAPI;

public class AgatusEventProxy extends DefaultNpcEventProxy implements AgatusAPI {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a pretty bad pattern to be extending a class without any changes at all. Is the issue here simply that this should be a higher-level api?

Instead of a DefaultNpcEventAPI maybe it should be a NpcEventAPI which returns a list or a map of NpcEvent objects.

interface NpcEventAPI {

  NpcEvent getEvent(EventType type);
  
  enum EventType {
    GENERIC, AGATUS, ...;
  }
}

The implementation can use the Agatus proxy and the generic npc event proxy, and in the plugin-side you can:
NpcEventAPI.getEvent(EventType.AGATUS) to get an NpcEvent with the info related to agatus.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.github.manolo8.darkbot.core.objects.facades;

import com.github.manolo8.darkbot.core.itf.Updatable;
import com.github.manolo8.darkbot.core.utils.ByteUtils;
import eu.darkbot.api.managers.DefaultNpcEventAPI;

import static com.github.manolo8.darkbot.Main.API;

public class DefaultNpcEventProxy extends Updatable implements DefaultNpcEventAPI {
public double time;
public String eventID;
public String npcName;
public String eventDescriptionID;
public String eventDescription;
public String npcLeftDescription;
public int npcCount;
public int bossCount;
public boolean eventActive;

@Override
public double getRemainingTime() {
return time;
}

@Override
public String getNpcName() {
return npcName;
}

@Override
public String getEventID() {
return eventID;
}

@Override
public String getEventDescription() {
return eventDescription;
}

@Override
public String getNpcLeftDescription() {
return npcLeftDescription;
}

@Override
public int npcLeft() {
return npcCount;
}

@Override
public int bossNpcLeft() {
return bossCount;
}

@Override
public DefaultNpcEventAPI.Status getStatus() {
if (this.eventActive) {
return Status.ACTIVE;
} else {
return Status.INACTIVE;
}
}

public void update() {
long data = API.readMemoryLong(address + 48) & ByteUtils.ATOM_MASK;

this.eventActive = API.readBoolean(data + 0x44);
this.time = API.readMemoryDouble(API.readMemoryLong(data + 0x50) + 0x38);
this.eventDescription = API.readMemoryString(API.readMemoryLong(data + 0x60));
this.npcLeftDescription = API.readMemoryString(API.readMemoryLong(data + 0x68));
this.eventDescriptionID = API.readMemoryString(API.readMemoryLong(data + 0x70));
this.eventID = API.readMemoryString(API.readMemoryLong(data + 0x78));
this.npcName = API.readMemoryString(API.readMemoryLong(data + 0x80));
this.npcCount = API.readInt(data + 0x88);
this.bossCount = API.readInt(data + 0x90);
}
}
Original file line number Diff line number Diff line change
@@ -1,77 +1,6 @@
package com.github.manolo8.darkbot.core.objects.facades;

import com.github.manolo8.darkbot.core.itf.Updatable;
import com.github.manolo8.darkbot.core.utils.ByteUtils;
import eu.darkbot.api.managers.NpcEventAPI;

import static com.github.manolo8.darkbot.Main.API;

public class NpcEventProxy extends Updatable implements NpcEventAPI {
public double time;
public String eventID;
public String eventName;
public String eventDescriptionID;
public String eventDescription;
public String npcLeftDescription;
public int npcCount;
public int bossCount;
public boolean eventActive;

@Override
public double getRemainingTime() {
return time;
}

@Override
public String getEventName() {
return eventName;
}

@Override
public String getEventID() {
return eventID;
}

@Override
public String getEventDescription() {
return eventDescription;
}

@Override
public String getNpcLeftDescription() {
return npcLeftDescription;
}

@Override
public int npcLeft() {
return npcCount;
}

@Override
public int bossNpcLeft() {
return bossCount;
}

@Override
public NpcEventAPI.Status getStatus() {
if (this.eventActive) {
return Status.ACTIVE;
} else {
return Status.INACTIVE;
}
}

public void update() {
long data = API.readMemoryLong(address + 48) & ByteUtils.ATOM_MASK;

this.eventActive = API.readBoolean(data + 0x44);
this.time = API.readMemoryDouble(API.readMemoryLong(data + 0x50) + 0x38);
this.eventDescription = API.readMemoryString(API.readMemoryLong(data + 0x60));
this.npcLeftDescription = API.readMemoryString(API.readMemoryLong(data + 0x68));
this.eventDescriptionID = API.readMemoryString(API.readMemoryLong(data + 0x70));
this.eventID = API.readMemoryString(API.readMemoryLong(data + 0x78));
this.eventName = API.readMemoryString(API.readMemoryLong(data + 0x80));
this.npcCount = API.readInt(data + 0x88);
this.bossCount = API.readInt(data + 0x90);
}
public class NpcEventProxy extends DefaultNpcEventProxy implements NpcEventAPI{
}
Loading