Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
osbuddy committed May 24, 2018
1 parent 8c8733d commit da8b08f
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 62 deletions.
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# osbuddy-community [![Discord](https://img.shields.io/discord/177282798799945729.svg)](https://discord.gg/osbuddy)
The OSBuddy Community API enables free, open source plugin development for OldSchool RuneScape.

Plugins merged into this repository will be made freely available for install via the Community tab of the OSBuddy client from 23rd May onwards.
Plugins merged into this repository will be made freely available for install via the Community tab of the OSBuddy client.

## Building a plugin
Your plugins must be built against the latest API, which can be built from source via the /api directory in this repository, or obtained from the [GitHub releases](https://github.com/RSBuddy/osbuddy-community/releases).
An example plugin is provided which shows other typical dependencies, which are managed using gradle. We suggest using IntelliJ IDEA to import the gradle project.

**This repository is currently a beta release until the OSBuddy update on 23rd May which will introduce the first community plugins. Please join us on Discord [#development](https://discord.gg/qqstZnZ) if you're interested in using the API at this stage.**
## Setting up the project
This is an initial commit, please check back shortly.
## Creating a plugin
This is an initial commit, please check back shortly.
Make sure you have run OSBuddy so that you have an OSBuddy folder in your user directory. This will contain loader.jar, which you will need to your plugin project's class path so that you can run your plugin.

To run your plugin (we recommend launching in Debug mode), launch the main class com.osbuddy.loader.Loader with the following VM arguments:
```
-Dplugin-classpath=out/production/classes
-Dplugin-resources=out/production/resources
-Dnofork=true
-Ddev=true
-Xmx512m
```

Your classpath and resources directories may differ depending on how you are building your code.

## Contributions
We will accept merge requests for contributions that match our [LICENSE](https://github.com/rsbuddy/osbuddy-community/LICENSE), and our contribution guidelines that will be made available here shortly.
We will accept merge requests for contributions that match the permissive [LICENSE](https://github.com/rsbuddy/osbuddy-community/LICENSE) used in this repository. Further guidelines that will be made available here shortly.
2 changes: 1 addition & 1 deletion api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'com.rsbuddy.osrs'
version '1.0-SNAPSHOT'
version '1.0'

sourceCompatibility = 1.8

Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/com/rsbuddy/osrs/PluginContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import com.rsbuddy.osrs.game.Game;

import java.net.URL;
import java.io.InputStream;
import java.util.concurrent.ScheduledExecutorService;

/**
Expand All @@ -52,7 +52,7 @@ public interface PluginContext {

<T> void set(String setting, T value);

URL resource(String name);
InputStream resource(String name);

void exit();

Expand Down
92 changes: 90 additions & 2 deletions api/src/main/java/com/rsbuddy/osrs/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,128 @@
*/
public interface Game {

/**
* Runs a task on the game thread once.
*
* @param task The callback.
* @param name A name for the task for profiling purposes.
*/
void once(Runnable task, String name);

/**
* Runs a task on the game thread each <tt>interval</tt>ms until it returns <tt>false</tt>.
*
* @param task The callback (which should return <tt>false</tt> to end execution.
* @param interval The number of milliseconds between callbacks.
* @param name A name for the task for profiling purposes.
*/
void loop(Callable<Boolean> task, long interval, String name);

/**
* An object to access game configs (such as NPC and item metadata).
*
* @return The singleton Configs interface.
*/
Configs configs();

Camera camera();

/**
* The local player's friends list.
*
* @return A {@link PlayerRegistry} containing the friends.
*/
PlayerRegistry<Friend> friends();

/**
* The local player's ignore list.
*
* @return A {@link PlayerRegistry} containing the ignores.
*/
PlayerRegistry<Ignore> ignores();

/**
* The local player's clan chat.
*
* @return An object to access the clan chat.
*/
ClanChat clanChat();

/**
* An object to access the game locations that are currently loaded.
*
* @return An object to access game locations.
*/
Locations locations();

/**
* An object to access the game's UI.
*
* @return An object to access game UI.
*/
Interfaces interfaces();

/**
* An object to access items that are currently on the ground.
*
* @return An object to access ground items.
*/
GroundItems items();

/**
* An object to access the context-sensitive right click menu ("mini-menu").
*
* @return An object to access the minimenu.
*/
MiniMenu miniMenu();

/**
* An object to access the loaded NPCs.
*
* @return An object to access NPCs.
*/
Npcs npcs();

/**
* An object to access the loaded players.
*
* @return An object to access players.
*/
Players players();

/**
* An object to access the loaded projectiles.
*
* @return An object to access projectiles.
*/
Projectiles projectiles();

/**
* An object to access the variables that make up certain player settings
* the player's state in various game content.
*
* @return An object to access variables.
*/
Variables vars();

/**
* An object to access the local player's skill levels and experience.
*
* @return An object to access skills and experience.
*/
Skills skills();

/**
* An object to access properties of the game's 3d rendering viewport
* and compute various projections.
*
* @return An object to access the viewport.
*/
Viewport viewport();

/**
* An object to access the various inventories that are cached by the game client.
*
* @return An object to access the game inventories.
*/
Inventories inventories();

GameState state();
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/com/rsbuddy/osrs/game/ui/Interfaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ public interface Interfaces {

GameTab currentGameTab();

void register(PaintHook hook, Paintable p);

void unregister(Paintable p);

}
7 changes: 7 additions & 0 deletions api/src/main/java/com/rsbuddy/osrs/game/ui/PaintHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.rsbuddy.osrs.game.ui;

public enum PaintHook {
CLIENT,
TLI,
WORLD,
}
9 changes: 9 additions & 0 deletions api/src/main/java/com/rsbuddy/osrs/game/ui/Paintable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.rsbuddy.osrs.game.ui;

import java.awt.Graphics2D;

public interface Paintable {

void paint(final Graphics2D g);

}
47 changes: 0 additions & 47 deletions api/src/main/java/com/rsbuddy/osrs/game/world/Camera.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public interface Locations {
* @param predicate The condition
* @param radius The radius to search
*/

Collection<Location> loaded(EnumSet<Location.Type> types, Predicate<Location> predicate, int radius);

Collection<Location> loaded(int id, EnumSet<Location.Type> types, Predicate<Location> predicate, int radius);
Expand Down
10 changes: 10 additions & 0 deletions api/src/main/java/com/rsbuddy/osrs/game/world/Viewport.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,14 @@ public interface Viewport {
Rectangle bounds();

Ellipse2D minimapBounds();

int camX();

int camY();

int camZ();

int camPitch();

int camYaw();
}
4 changes: 3 additions & 1 deletion plugins/example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ repositories {
}

dependencies {
compile files('../../api/build/libs/api-1.0-SNAPSHOT.jar')
compile files(System.getProperty("user.home") + '/OSBuddy/loader.jar')
compile files('../../api/build/libs/api-1.0.jar')
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.6'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.9'
compile group: 'com.google.guava', name: 'guava', version: '25.0-jre'
compile group: 'com.google.inject', name: 'guice', version: '4.2.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import com.rsbuddy.osrs.PluginContext;
import com.rsbuddy.osrs.content.ui.Bank;
import com.rsbuddy.osrs.game.Game;
import com.rsbuddy.osrs.game.ui.Interfaces;
import com.rsbuddy.osrs.game.ui.PaintHook;
import com.rsbuddy.osrs.game.ui.Paintable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.awt.*;

public class ExamplePlugin implements Plugin {
public class ExamplePlugin implements Plugin, Paintable {

final Logger log = LoggerFactory.getLogger(getClass());

Expand All @@ -19,20 +23,30 @@ public class ExamplePlugin implements Plugin {
@Inject
Bank bank;

@Inject
Interfaces ui;

boolean running;

@Override
public void init(PluginContext pluginContext) {
running = true;
ui.register(PaintHook.TLI, this);
game.loop(() -> {
log.info(bank.open() ? "Your bank is open!!" : "Your bank isn't open.");
log.info("Tick: " + game.time());
return running;
}, 1000, "Bank check loop");
}

@Override
public void dispose(PluginContext pluginContext) {
running = false;
ui.unregister(this);
}

@Override
public void paint(Graphics2D g) {
g.drawString(bank.open() ? "Your bank is open!!" : "Your bank isn't open.", 20, 40);
}

}

0 comments on commit da8b08f

Please sign in to comment.