diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..4f58dce
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..a0a7c35
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ CyanAccelSprint
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..ec1937b
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+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.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/config.yml b/config.yml
new file mode 100644
index 0000000..2d3eaf9
--- /dev/null
+++ b/config.yml
@@ -0,0 +1,7 @@
+prefix: "&8[&3CyanAccelSprint&8] "
+sprint: # delay:speedlevel
+ 1: 1
+ 2: 2
+ 3: 4
+ 4: 8
+ 5: 16
\ No newline at end of file
diff --git a/plugin.yml b/plugin.yml
new file mode 100644
index 0000000..ee47858
--- /dev/null
+++ b/plugin.yml
@@ -0,0 +1,10 @@
+name: CyanAccelSprint
+version: 1.0
+author: Cyanoure
+main: ga.cyanoure.cyanaccelsprint.Main
+website: http://www.cyanoure.ga/
+description: Gyorsulo Sprint Rendszer
+commands:
+ casreload:
+ description: Config ujratoltese
+ permission: cyanaccelsprint.admin
\ No newline at end of file
diff --git a/src/ga/cyanoure/cyanaccelsprint/Main.java b/src/ga/cyanoure/cyanaccelsprint/Main.java
new file mode 100644
index 0000000..b10c19d
--- /dev/null
+++ b/src/ga/cyanoure/cyanaccelsprint/Main.java
@@ -0,0 +1,145 @@
+package ga.cyanoure.cyanaccelsprint;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.event.player.PlayerToggleSprintEvent;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+
+public class Main extends JavaPlugin implements Listener, CommandExecutor{
+ public FileConfiguration config;
+
+ class SprintUser {
+ public Player Player;
+ public double SprintSince;
+ public int PotionStrength = 0;
+ }
+
+ List SprintList;
+
+ private void pluginMessage(String msg) {
+ String prefix = this.config.getString("prefix");
+ getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',prefix+msg));
+ }
+
+ private void LoadConfig() {
+ this.saveDefaultConfig();
+ //this.getConfig().addDefault("", "");
+ //this.getConfig().options().copyDefaults(true);
+ this.config = this.getConfig();
+ }
+
+ private void ReloadConfig() {
+ this.reloadConfig();
+ this.config = this.getConfig();
+ }
+
+ @Override
+ public void onEnable() {
+ LoadConfig();
+ SprintList = new ArrayList();
+ getServer().getPluginManager().registerEvents(this, this);
+ this.getCommand("casreload").setExecutor(this);
+
+ pluginMessage("&2Plugin és konfigurációja betöltve.");
+
+ new UpdateChecker(this,79042).getLatestVersion(version -> {
+ pluginMessage("Jelenlegi verzió: "+this.getDescription().getVersion());
+ pluginMessage("Legújabb verzió a spigotmc.org-on: "+version);
+ pluginMessage("Link: https://www.spigotmc.org/resources/cyanaccelsprint.79042/");
+ });;
+ }
+
+ @Override
+ public void onDisable() {
+ pluginMessage("&2Plugin letiltva.");
+ }
+
+ @EventHandler
+ public void onSprint(PlayerToggleSprintEvent event) {
+ Player p = event.getPlayer();
+
+ // Az ellenőrzés fordítva működik, mert ha nem sprintelt, akkor sprintelni fog, ha sprintel, akkor nem fog.
+ if(!p.isSprinting()) {
+ SprintUser newItem = new SprintUser();
+ newItem.Player = p;
+ newItem.SprintSince = System.currentTimeMillis();
+ SprintList.add(newItem);
+ }else {
+ for(int i = 0; i < SprintList.size(); i++) {
+ if(SprintList.get(i).Player.getName() == p.getName()) {
+ SprintList.remove(i);
+ p.removePotionEffect(PotionEffectType.SPEED);
+ break;
+ }
+ }
+ }
+ }
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent e) {
+ Player p = e.getPlayer();
+ for(int i = 0; i < SprintList.size(); i++) {
+ if(SprintList.get(i).Player.getName() == p.getName()) {
+ SprintList.remove(i);
+ p.removePotionEffect(PotionEffectType.SPEED);
+ break;
+ }
+ }
+ }
+
+ @EventHandler
+ public void onMove(PlayerMoveEvent e) {
+ Player p = e.getPlayer();
+ for(int i = 0; i < SprintList.size(); i++) {
+ if(SprintList.get(i).Player.getName() == p.getName()) {
+ double SprintSince = SprintList.get(i).SprintSince;
+ double TimeNow = System.currentTimeMillis();
+ int ElteltIdo = (int) ((TimeNow - SprintSince)/1000);
+ int speedLevel = 0;
+ Object[] SprintDurations = this.config.getConfigurationSection("sprint").getKeys(false).toArray();
+ for(int j = 0; j < SprintDurations.length; j++) {
+ int ido = Integer.parseInt(SprintDurations[j].toString());
+ if(ElteltIdo >= ido) {
+ speedLevel = this.config.getInt("sprint."+String.valueOf(ido));
+ }
+ }
+ if(speedLevel > 0 && SprintList.get(i).PotionStrength != speedLevel) {
+ p.removePotionEffect(PotionEffectType.SPEED);
+ p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,speedLevel));
+ }
+ SprintList.get(i).PotionStrength = speedLevel;
+ break;
+ }
+ }
+ }
+
+ @EventHandler
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if(sender instanceof Player) {
+ Player p = (Player)sender;
+ if(!p.hasPermission("cyanaccelsprint.admin")) {
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&',this.config.getString("prefix")+"&cEhhez nincs jogod!"));
+ return true;
+ }
+ }
+
+ this.reloadConfig();
+ this.config = this.getConfig();
+ sender.sendMessage(ChatColor.translateAlternateColorCodes('&',this.config.getString("prefix")+"&2Konfiguráció újratöltve."));
+
+ return true;
+ }
+}
diff --git a/src/ga/cyanoure/cyanaccelsprint/UpdateChecker.java b/src/ga/cyanoure/cyanaccelsprint/UpdateChecker.java
new file mode 100644
index 0000000..4b4f63b
--- /dev/null
+++ b/src/ga/cyanoure/cyanaccelsprint/UpdateChecker.java
@@ -0,0 +1,33 @@
+package ga.cyanoure.cyanaccelsprint;
+
+import org.bukkit.Bukkit;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Scanner;
+import java.util.function.Consumer;
+
+public class UpdateChecker {
+
+ private Main plugin;
+ private int resourceId;
+
+ public UpdateChecker(Main plugin, int resourceId) {
+ this.plugin = plugin;
+ this.resourceId = resourceId;
+ }
+
+ public void getLatestVersion(Consumer consumer) {
+ Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
+ try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream();
+ Scanner scanner = new Scanner(inputStream)) {
+ if (scanner.hasNext()) {
+ consumer.accept(scanner.next());
+ }
+ } catch (IOException exception) {
+ plugin.getLogger().info("Update checker is broken, can't find an update!" + exception.getMessage());
+ }
+ });
+ }
+}
\ No newline at end of file