Revert "Merge branch 'master' into master"
This reverts commit16561db1d6, reversing changes made toc2710ada6b.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.defaultworld;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("defaultworld")
|
||||
public interface DefaultWorldConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "defaultWorld",
|
||||
name = "Default world",
|
||||
description = "World to use as default one"
|
||||
)
|
||||
default int getWorld()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.defaultworld;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import java.io.IOException;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.SessionOpen;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.util.WorldUtil;
|
||||
import net.runelite.http.api.worlds.World;
|
||||
import net.runelite.http.api.worlds.WorldClient;
|
||||
import net.runelite.http.api.worlds.WorldResult;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Default World",
|
||||
description = "Enable a default world to be selected when launching the client",
|
||||
tags = {"home"}
|
||||
)
|
||||
@Slf4j
|
||||
public class DefaultWorldPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private DefaultWorldConfig config;
|
||||
|
||||
private final WorldClient worldClient = new WorldClient();
|
||||
private int worldCache;
|
||||
private boolean worldChangeRequired;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
worldChangeRequired = true;
|
||||
applyWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
worldChangeRequired = true;
|
||||
changeWorld(worldCache);
|
||||
}
|
||||
|
||||
@Provides
|
||||
DefaultWorldConfig getConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(DefaultWorldConfig.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onSessionOpen(SessionOpen event)
|
||||
{
|
||||
worldChangeRequired = true;
|
||||
applyWorld();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
applyWorld();
|
||||
}
|
||||
|
||||
private void changeWorld(int newWorld)
|
||||
{
|
||||
if (!worldChangeRequired || client.getGameState() != GameState.LOGIN_SCREEN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
worldChangeRequired = false;
|
||||
int correctedWorld = newWorld < 300 ? newWorld + 300 : newWorld;
|
||||
|
||||
// Old School RuneScape worlds start on 301 so don't even bother trying to find lower id ones
|
||||
// and also do not try to set world if we are already on it
|
||||
if (correctedWorld <= 300 || client.getWorld() == correctedWorld)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final WorldResult worldResult = worldClient.lookupWorlds();
|
||||
|
||||
if (worldResult == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final World world = worldResult.findWorld(correctedWorld);
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
final net.runelite.api.World rsWorld = client.createWorld();
|
||||
rsWorld.setActivity(world.getActivity());
|
||||
rsWorld.setAddress(world.getAddress());
|
||||
rsWorld.setId(world.getId());
|
||||
rsWorld.setPlayerCount(world.getPlayers());
|
||||
rsWorld.setLocation(world.getLocation());
|
||||
rsWorld.setTypes(WorldUtil.toWorldTypes(world.getTypes()));
|
||||
|
||||
client.changeWorld(rsWorld);
|
||||
log.debug("Applied new world {}", correctedWorld);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("World {} not found.", correctedWorld);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.warn("Error looking up world {}. Error: {}", correctedWorld, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyWorld()
|
||||
{
|
||||
if (worldCache == 0)
|
||||
{
|
||||
worldCache = client.getWorld();
|
||||
log.debug("Stored old world {}", worldCache);
|
||||
}
|
||||
|
||||
final int newWorld = config.getWorld();
|
||||
changeWorld(newWorld);
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,13 @@ public class ClientLoader
|
||||
|
||||
switch (updateCheckMode)
|
||||
{
|
||||
case AUTO:
|
||||
default:
|
||||
return loadRLPlus(config);
|
||||
case VANILLA:
|
||||
return loadVanilla(config);
|
||||
case NONE:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e)
|
||||
@@ -102,7 +107,7 @@ public class ClientLoader
|
||||
private static Applet loadFromClass(final RSConfig config, final Class<?> clientClass) throws IllegalAccessException, InstantiationException
|
||||
{
|
||||
final Applet rs = (Applet) clientClass.newInstance();
|
||||
rs.setStub(new RSAppletStub());
|
||||
rs.setStub(new RSAppletStub(config));
|
||||
return rs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,133 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.rs;
|
||||
|
||||
import java.applet.AppletContext;
|
||||
import java.applet.AppletStub;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public class RSAppletStub implements AppletStub
|
||||
@RequiredArgsConstructor
|
||||
class RSAppletStub implements AppletStub
|
||||
{
|
||||
|
||||
public static final Logger logger = Logger.getLogger(RSAppletStub.class.getSimpleName());
|
||||
|
||||
private static final HashMap<String, String> params = new HashMap<String, String>();
|
||||
private static final HashMap<String, String> cfg = new HashMap<String, String>();
|
||||
private static URL codebase;
|
||||
|
||||
static
|
||||
{
|
||||
cfg.put("privacyurl", "http://www.jagex.com/g=oldscape/privacy/privacy.ws");
|
||||
cfg.put("window_preferredheight", "600");
|
||||
cfg.put("msg", "new_version_link=http://oldschool.runescape.com/");
|
||||
cfg.put("applet_minwidth", "765");
|
||||
cfg.put("adverturl", "http://www.runescape.com/g=oldscape/bare_advert.ws");
|
||||
cfg.put("cachedir", "oldschool");
|
||||
cfg.put("window_preferredwidth", "800");
|
||||
cfg.put("applet_maxheight", "2160");
|
||||
cfg.put("win_sub_version", "1");
|
||||
cfg.put("browsercontrol_win_x86_jar", "browsercontrol_0_-1928975093.jar");
|
||||
cfg.put("other_sub_version", "2");
|
||||
cfg.put("initial_jar", "gamepack_4840368.jar");
|
||||
cfg.put("advert_height", "96");
|
||||
cfg.put("title", "Old School RuneScape");
|
||||
cfg.put("storebase", "0");
|
||||
cfg.put("initial_class", "client.class");
|
||||
cfg.put("applet_maxwidth", "5760");
|
||||
cfg.put("download", "1230228");
|
||||
cfg.put("termsurl", "http://www.jagex.com/g=oldscape/terms/terms.ws");
|
||||
cfg.put("codebase", "http://oldschool1.runescape.com/");
|
||||
cfg.put("mac_sub_version", "2");
|
||||
cfg.put("browsercontrol_win_amd64_jar", "browsercontrol_1_1674545273.jar");
|
||||
cfg.put("applet_minheight", "503");
|
||||
cfg.put("viewerversion", "124");
|
||||
}
|
||||
|
||||
public RSAppletStub()
|
||||
{
|
||||
try
|
||||
{
|
||||
parseParams(new FileInputStream(new File("./params.txt")));
|
||||
String worldListKey = null;
|
||||
for (Map.Entry<String, String> paramEntry : params.entrySet())
|
||||
{
|
||||
String key = paramEntry.getKey();
|
||||
String value = paramEntry.getValue();
|
||||
if (value.contains("slr.ws"))
|
||||
{
|
||||
worldListKey = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
codebase = new URL("http://runeliteplus-ps.ddns.net"); //host
|
||||
params.put(worldListKey, "http://" + codebase.getHost());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseParams(InputStream stream) throws IOException
|
||||
{
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
int idx = line.indexOf('=');
|
||||
if (idx != -1)
|
||||
{
|
||||
String key = line.substring(0, idx);
|
||||
String val = line.substring(idx + 1);
|
||||
if (key.equals("param"))
|
||||
{
|
||||
idx = val.indexOf('=');
|
||||
key = val.substring(0, idx);
|
||||
val = val.substring(idx + 1);
|
||||
params.put(key, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg.put(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void log(String format, Object... params)
|
||||
{
|
||||
System.out.printf(format + "\n", params);
|
||||
}
|
||||
private final RSConfig config;
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDocumentBase()
|
||||
{
|
||||
return codebase;
|
||||
return getCodeBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getCodeBase()
|
||||
{
|
||||
return codebase;
|
||||
try
|
||||
{
|
||||
return new URL(config.getCodeBase());
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name)
|
||||
{
|
||||
return params.get(name);
|
||||
return config.getAppletProperties().get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,4 +77,4 @@ public class RSAppletStub implements AppletStub
|
||||
public void appletResize(int width, int height)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user