本文整理汇总了Java中de.dakror.gamesetup.util.Helper.getURLContent方法的典型用法代码示例。如果您正苦于以下问题:Java Helper.getURLContent方法的具体用法?Java Helper.getURLContent怎么用?Java Helper.getURLContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.dakror.gamesetup.util.Helper
的用法示例。
在下文中一共展示了Helper.getURLContent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getApps
import de.dakror.gamesetup.util.Helper; //导入方法依赖的package包/类
public static void getApps() {
try {
apps.clear();
if (DakrorLauncher.internet) {
JSONArray a = new JSONArray(Helper.getURLContent(new URL("http://dakror.de/app/get")));
for (int i = 0; i < a.length(); i++) {
JSONObject o = a.getJSONObject(i);
if (o.getInt("TYPE") == 0) {
apps.add(new App(o.getInt("ID"), o.getInt("STATE"), o.getInt("DATE"), o.getString("NAME"), o.getString("IMAGE"), o.getString("DESCRIPTION"), o.getLong("VERSION")));
}
}
} else {
for (File f : new File(CFG.DIR, DakrorLauncher.getLastLogin()[1] + "/apps/").listFiles()) {
apps.add(new App(0, 0, 0, f.getName(), f.getName().toLowerCase() + ".png", "", 1));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: sendScore
import de.dakror.gamesetup.util.Helper; //导入方法依赖的package包/类
public static void sendScore() {
try {
if (isWorldScorePosted(Game.currentGame.worldCreated)) {
JOptionPane.showMessageDialog(null, "Du hast deinen Punktestand auf dieser Karte bereits in der Bestenliste platziert!", "Bereits platziert!", JOptionPane.ERROR_MESSAGE);
return;
}
String response = Helper.getURLContent(new URL("http://dakror.de/villagedefense/api/scores.php?USERNAME=" + urlencode(CFG.USERNAME) + "&SCORE=" + Game.currentGame.getPlayerScore()));
System.out.println(response);
if (!response.equals("false")) {
JOptionPane.showMessageDialog(null, "Dein Punktestand wurde erfolgreich in der Bestenliste platziert.", "Platzieren erfolgreich!", JOptionPane.INFORMATION_MESSAGE);
addWorldScorePosted(Game.currentGame.worldCreated);
Game.currentGame.scoreSent = true;
} else JOptionPane.showMessageDialog(null, "Dein Punktestand konnte nicht in der Bestenliste platziert werden!", "Platzieren fehlgeschlagen!", JOptionPane.ERROR_MESSAGE);
} catch (Exception e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(null, "Dein Punktestand konnte nicht in der Bestenliste platziert werden!\nMöglicherweise bist du nicht mit dem Internet verbunden.", "Platzieren fehlgeschlagen!", JOptionPane.ERROR_MESSAGE);
}
}
示例3: init
import de.dakror.gamesetup.util.Helper; //导入方法依赖的package包/类
public static void init() {
try {
JSONArray a = new JSONArray(Helper.getURLContent(Object.class.getResource("/entities.entlist")));
entityTypes = new ArrayList<>();
for (int i = 0; i < a.length(); i++) {
JSONObject o = a.getJSONObject(i);
EntityType ot = new EntityType();
ot.tileset = o.getString("t");
ot.tx = o.getInt("x");
ot.ty = o.getInt("y");
ot.width = o.getInt("w");
ot.height = o.getInt("h");
ot.bumpX = o.getInt("bx");
ot.bumpY = o.getInt("by");
ot.bumpWidth = o.getInt("bw");
ot.bumpHeight = o.getInt("bh");
entityTypes.add(ot);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
示例4: loadConfig
import de.dakror.gamesetup.util.Helper; //导入方法依赖的package包/类
public static void loadConfig() {
try {
config = new JSONObject(Helper.getURLContent(Game.class.getResource("/config.json")));
Const.DECONSTRUCT_FACTOR = (float) config.getDouble("deconstruct");
Const.UPGRADE_FACTOR = (float) config.getDouble("upgrade");
Const.BUILDING_MAX_LEVEL = config.getInt("maxlevel");
Const.CITY_TAKEOVERS = config.getInt("takeovers");
Const.TAKEOVER_FACTOR = (float) config.getDouble("takeover_factor");
Const.MARCH_SECONDS = config.getInt("troops");
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: getUsersFromWebsite
import de.dakror.gamesetup.util.Helper; //导入方法依赖的package包/类
public static JSONObject getUsersFromWebsite() {
try {
return new JSONObject(Helper.getURLContent(new URL("http://dakror.de/mp-api/users")));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例6: initEntities
import de.dakror.gamesetup.util.Helper; //导入方法依赖的package包/类
public void initEntities() throws JSONException {
components.clear();
if (getClass().getResource("/maps/" + name + "/" + name + ".json") != null) {
JSONArray e = new JSONArray(Helper.getURLContent(getClass().getResource("/maps/" + name + "/" + name + ".json"), "UTF-8"));
for (int i = 0; i < e.length(); i++) {
JSONObject o = e.getJSONObject(i);
Entity entity = null;
if (o.has("m")) {
if (o.getJSONObject("m").has("npc") && o.getJSONObject("m").getBoolean("npc")) entity = new NPC(o.getInt("x") * (World.TILE_SIZE / 32), o.getInt("y") * (World.TILE_SIZE / 32), EntityType.entityTypes.get(o.getInt("i")), o.getJSONObject("m"));
else if (o.getJSONObject("m").has("itemID")) entity = new ItemDrop(o.getInt("x") * (World.TILE_SIZE / 32), o.getInt("y") * (World.TILE_SIZE / 32), o.getJSONObject("m"));
else if (o.getJSONObject("m").has("animID")) entity = new AnimationSpot(o.getInt("x") * (World.TILE_SIZE / 32), o.getInt("y") * (World.TILE_SIZE / 32), o.getJSONObject("m"));
else entity = new Object(o.getInt("x") * (World.TILE_SIZE / 32), o.getInt("y") * (World.TILE_SIZE / 32), EntityType.entityTypes.get(o.getInt("i")), o.getJSONObject("m"));
} else entity = new Object(o.getInt("x") * (World.TILE_SIZE / 32), o.getInt("y") * (World.TILE_SIZE / 32), EntityType.entityTypes.get(o.getInt("i")), new JSONObject());
if (o.has("e")) entity.setEventFunctions(o.getJSONObject("e"));
entity.uid = o.getInt("uid");
if (entity instanceof NPC) ((NPC) entity).checkForQuestState();
if (o.has("m") && o.getJSONObject("m").has("flags")) entity.enabled = FlagManager.matchesFlags(o.getJSONObject("m").getString("flags"));
addEntity(entity);
}
}
}
示例7: Editor
import de.dakror.gamesetup.util.Helper; //导入方法依赖的package包/类
public Editor() {
super("Liturfaliar Cest Editor");
Item.init();
Animation.init();
currentEditor = this;
setSize(1280, 720);
setLocationRelativeTo(null);
setResizable(false);
setIconImage(Game.getImage("system/editor.png"));
setDefaultCloseOperation(EXIT_ON_CLOSE);
devMode = new File(System.getProperty("user.dir"), "src").exists();
try {
if (devMode) {
entlist = new File(System.getProperty("user.dir"), "src/main/resources/entities.entlist");
entities = new JSONArray(Helper.getFileContent(entlist));
} else entities = new JSONArray(Helper.getURLContent(getClass().getResource("/entities.entlist")));
} catch (JSONException e1) {
e1.printStackTrace();
}
initJMenuBar();
initComponents();
setVisible(true);
}