Skip to content

Commit

Permalink
Merge pull request #15 from PoutineQc/update
Browse files Browse the repository at this point in the history
1.10 Update
  • Loading branch information
ChagnonSebastien committed Jun 27, 2016
2 parents c89aa72 + 46fe075 commit 4980337
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 37 deletions.
Empty file added .gitignore
Empty file.
9 changes: 9 additions & 0 deletions Bukkit/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="C:/Users/Seb/Desktop/Minecraft_plugin/Libraries/Minecraft19/worldedit-bukkit-6.1.1-SNAPSHOT-dist.jar"/>
<classpathentry kind="lib" path="C:/Users/Seb/Desktop/Minecraft_plugin/Libraries/Vault.jar"/>
<classpathentry kind="lib" path="C:/Users/Seb/Desktop/Minecraft_plugin/Libraries/minecraft 110/spigot-1.10.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Bukkit/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CubeRunner</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Bukkit/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
1 change: 1 addition & 0 deletions Bukkit/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/me/
2 changes: 1 addition & 1 deletion Bukkit/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CubeRunner
main : me.poutineqc.cuberunner.CubeRunner
version: 2.4.2
version: 2.5
description: Blocks are falling over your head! Can you outrun them?
load: postworld
author: PoutineQc
Expand Down
40 changes: 21 additions & 19 deletions Bukkit/src/me/poutineqc/cuberunner/CubeRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CubeRunner extends JavaPlugin {

private static CubeRunner plugin;
public static final String name = "CubeRunner";

private Updater updater;
private Configuration config;
private MySQL mysql = new MySQL();
Expand All @@ -44,20 +44,20 @@ public class CubeRunner extends JavaPlugin {

private Economy economy;
public static String NMS_VERSION;
public static boolean oneNine;
public static boolean aboveOneNine;

public void onEnable() {
plugin = this;
NMS_VERSION = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
oneNine = NMS_VERSION.startsWith("v1_9");
NMS_VERSION = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
aboveOneNine = NMS_VERSION.startsWith("v1_9") || NMS_VERSION.startsWith("v1_1") || NMS_VERSION.startsWith("v2");

config = new Configuration(this);
if (config.lookForUpdates)
updater = new Updater(this);

if (!initialiseEconomy())
return;

loadLanguages();
connectMySQL();
arenaData = new ArenaData(this);
Expand All @@ -69,7 +69,7 @@ public void onEnable() {

getCommand("cuberunner").setExecutor(new ListenerCommand());
getCommand("cuberunner").setTabCompleter(new ListenerTabComplete());

enableListeners();

try {
Expand All @@ -79,7 +79,7 @@ public void onEnable() {
} catch (IOException e) {
e.printStackTrace();
}

Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
Expand All @@ -97,41 +97,42 @@ public void onDisable() {

if (config.lookForUpdates)
updater.stop();

if (mysql.hasConnection())
mysql.close();
else
arenaData.loadArenaData();

logger.info(pdfFile.getName() + " has been diabled");
}

public void reload() {
updater.stop();
Language.clear();

config.loadConfiguration(this);
if (config.lookForUpdates)
updater = new Updater(this);

if (!initialiseEconomy())
return;

loadLanguages();

playerData.clear();
playerData.loadViews();
playerData.loadPlayers(this);
achievementManager = new AchievementManager(this);
CRSign.setVariables(this);

Arena.loadExistingArenas();
CRSign.loadAllSigns();
}

public void connectMySQL() {
if (config.mysql) {
mysql = new MySQL(this, config.host, config.port, config.database, config.user, config.password, config.tablePrefix);
mysql = new MySQL(this, config.host, config.port, config.database, config.user, config.password,
config.tablePrefix);
} else {
mysql = new MySQL(this);
}
Expand Down Expand Up @@ -180,6 +181,7 @@ public Economy getEconomy() {
private void enableListeners() {
PluginManager pm = getServer().getPluginManager();

pm.registerEvents(updater, this);
pm.registerEvents(playerData, this);
pm.registerEvents(new ListenerPlayerDamage(), this);
pm.registerEvents(new ListenerPlayerTeleport(), this);
Expand All @@ -191,8 +193,8 @@ private void enableListeners() {
pm.registerEvents(new ListenerSignBreak(), this);
pm.registerEvents(new ListenerInventoryClick(), this);
pm.registerEvents(new ListenerEntityChangeBlock(), this);
if (oneNine)

if (aboveOneNine)
pm.registerEvents(new ListenerEntityGlide(), this);
}

Expand All @@ -211,7 +213,7 @@ public ArenaData getArenaData() {
public PlayerData getPlayerData() {
return playerData;
}

public static CubeRunner get() {
return plugin;
}
Expand Down
2 changes: 0 additions & 2 deletions Bukkit/src/me/poutineqc/cuberunner/MySQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public void connect() {
try {
connection = DriverManager.getConnection(
"jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true", user, password);
plugin.getLogger().info("[MySQL] The connection to MySQL is made!");
} catch (SQLException e) {
plugin.getLogger().info("[MySQL] The connection to MySQL couldn't be made! reason: " + e.getMessage());
}
Expand All @@ -99,7 +98,6 @@ public void close() {
try {
if (connection != null) {
connection.close();
plugin.getLogger().info("[MySQL] The connection to MySQL is ended successfully!");
}
} catch (SQLException e) {
plugin.getLogger().info("[MySQL] The connection couldn't be closed! reason: " + e.getMessage());
Expand Down
36 changes: 22 additions & 14 deletions Bukkit/src/me/poutineqc/cuberunner/Updater.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package me.poutineqc.cuberunner;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;

import org.bukkit.Bukkit;
Expand All @@ -18,7 +22,6 @@
public final class Updater implements Listener {

private static final String spigotPage = "https://www.spigotmc.org/resources/cuberunner.19715/";
private static final String versionPage = "http://www.poutineqc.ca/pluginVersion.txt";

private final CubeRunner plugin;
private final int id;
Expand Down Expand Up @@ -46,30 +49,35 @@ public void onPlayerJoin(PlayerJoinEvent event) {
}

private void checkForLastVersion(CubeRunner plugin) {
boolean next = false;

try {
lastVersion = getInfoFromServer();
} catch (IOException e) {
plugin.getLogger().warning("Could not find the latest version available.");
stop();
return;
}

lastVersion = (next) ? latestVersion.equalsIgnoreCase(plugin.getDescription().getVersion()) : true;
}

private boolean getInfoFromServer() throws IOException {
boolean next = false;
URL oracle = new URL(spigotPage);
URLConnection urlConn = oracle.openConnection();
urlConn.addRequestProperty("User-Agent", "Mozilla/4.76");
InputStream is = urlConn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is, 4 * 1024);
BufferedReader in = new BufferedReader(new InputStreamReader(bis, StandardCharsets.UTF_8));

URL url = new URL(versionPage);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

while ((latestVersion = in.readLine()) != null && !next) {
if (latestVersion.equalsIgnoreCase(CubeRunner.name))
next = true;
}
latestVersion = null;
String inputLine;
while ((inputLine = in.readLine()) != null && latestVersion == null)
if (inputLine.matches("^.*?([1-9][0-9]?\\.[1-9][0-9]?.*)$") && inputLine.contains(plugin.getName()))
latestVersion = inputLine.replaceAll(" ", "").replace(plugin.getName(), "").replaceAll("<[^>]*>", "");

in.close();
return next;
if (latestVersion == null) {
throw new IOException("Could not find the version on the page.");
}

return latestVersion.equalsIgnoreCase(plugin.getDescription().getVersion());
}

private void notifyConsole(CubeRunner plugin) {
Expand Down
2 changes: 1 addition & 1 deletion Bukkit/src/me/poutineqc/cuberunner/game/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ public void run() {
for (User user : arena.users) {
if (cooldownTimer % 20.0 == 0) {

Sound sound = CubeRunner.oneNine ? Sound.valueOf("UI_BUTTON_CLICK")
Sound sound = CubeRunner.aboveOneNine ? Sound.valueOf("UI_BUTTON_CLICK")
: Sound.valueOf("CLICK");

user.getPlayer().playSound(user.getPlayer().getLocation(), sound, 1, 1);
Expand Down

0 comments on commit 4980337

Please sign in to comment.