Skip to content

Commit

Permalink
configurable speed multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
theTd committed Apr 7, 2022
1 parent d5bb851 commit f56cb30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
import java.util.Set;

public class TCExpressPlugin extends JavaPlugin implements Listener {
private final static double MAX_SPEED = 2;
private final static int BUFFER_LENGTH = 5;
private final static int ADJUST_LENGTH = 20;
private final static double NORMAL_SPEED = 0.4;

private double maxSpeed = 2;

private final Set<String> effectiveWorlds = new HashSet<>();

@Override
Expand All @@ -35,6 +36,8 @@ public void onEnable() {
getLogger().warning("no effective worlds defined, plugin may not work.");
}

maxSpeed = NORMAL_SPEED * getConfig().getDouble("mul", 2);

getServer().getPluginManager().registerEvents(this, this);
}

Expand Down Expand Up @@ -120,7 +123,7 @@ void onMove(VehicleMoveEvent e) {

double s = (double) freeLength / ADJUST_LENGTH;
if (s > 1) s = 1;
double speed = NORMAL_SPEED + (MAX_SPEED - NORMAL_SPEED) * s;
double speed = NORMAL_SPEED + (maxSpeed - NORMAL_SPEED) * s;
minecart.setMaxSpeed(speed);
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ effective_worlds:
- world
- world_nether
- world_the_end

mul: 2

0 comments on commit f56cb30

Please sign in to comment.