Skip to content

Commit fa85868

Browse files
authored
Uploaded source
1 parent 2e0c931 commit fa85868

File tree

6 files changed

+357
-0
lines changed

6 files changed

+357
-0
lines changed

CHANGELOG

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
1.0:
2+
Initial release
3+
4+
1.1:
5+
Changed constant multiplier to a variable one(commands)
6+
Changed "load" and "unload" messages
7+
8+
1.1.1:
9+
Added more feedback on commands
10+
11+
1.2:
12+
Sign-commands
13+
fly-signs
14+
15+
1.2.1:
16+
Removed forgotten debug message spamming console
17+
18+
1.3:
19+
Cmd uses now permissions
20+
21+
1.3.1:
22+
Fixed nofly bug
23+
24+
1.4:
25+
Full permissions support
26+
27+
1.5:
28+
New event API
29+
1.2.3 -support
30+
31+
1.6:
32+
1.2.5 -support
33+
34+
1.6.2:
35+
Building against 1.4.6
36+
37+
1.6.3:
38+
Building against 1.5.2
39+
Fixing version numbers
40+
41+
13.2
42+
Migration to SpigotAPI
43+
44+
14.0
45+
VehicleMoveEvent fix
46+
47+
15.0.3
48+
compatibility update for MC1.15+
49+
50+
16.0.3
51+
stability update
52+
fixed CraftBukkit ignoring the global speed.
53+
54+
17.0.2
55+
Added support for 1.17, updated mapping and fixed "[msp] fly".
56+
Only tested on Spigot as other forks are not available yet.
57+
Backwards compatibility untested, but should work fine,
58+
please note there is currently cap at speed 4 when dynamically
59+
changing speed due to some strange minecart behavior that could
60+
occur when moving faster in versions grater than 1.13, if you
61+
need faster speed and have an older server version you can
62+
simply use an older version of this resource.
63+
64+
17.0.3
65+
This is just a quick update to fix a mistake i made in spelling.
66+
67+
68+
18.0.1
69+
Migrated from the SpigotAPI to the PaperAPI and replaced all spigot
70+
packages with their bukkit equivalents for maximum compatibility
71+
Changed the blue text to a more modern style as requested by a multiple users
72+
forced a global minecart speed limit of 4 (forgot to cap global in the last update)
73+
it is now possible to use decimal numbers for a more specific speed
74+
Fully compatible with Bukkit, Spigot, Paper and all it's forks
75+
[ https://imgur.com/a/4T1SLcZ ]

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package fi.dy.esav.Minecart_speedplus;
2+
3+
import java.util.logging.Logger;
4+
import org.bukkit.ChatColor;
5+
import org.bukkit.command.Command;
6+
import org.bukkit.command.CommandSender;
7+
import org.bukkit.entity.Player;
8+
import org.bukkit.plugin.Plugin;
9+
import org.bukkit.plugin.PluginManager;
10+
import org.bukkit.plugin.java.JavaPlugin;
11+
12+
public class Minecart_speedplus extends JavaPlugin {
13+
Logger log = Logger.getLogger("Minecraft");
14+
15+
private final Minecart_speedplusVehicleListener VehicleListener = new Minecart_speedplusVehicleListener(this);
16+
17+
private final Minecart_speedplusSignListener SignListener = new Minecart_speedplusSignListener(this);
18+
19+
static double speedmultiplier = 1.25D;
20+
21+
boolean result;
22+
23+
double multiplier;
24+
25+
public static double getSpeedMultiplier() {
26+
return speedmultiplier;
27+
}
28+
29+
public boolean setSpeedMultiplier(double multiplier) {
30+
if ((((0.0D < multiplier) ? 1 : 0) & ((multiplier <= 4.0D) ? 1 : 0)) != 0) {
31+
speedmultiplier = multiplier;
32+
return true;
33+
}
34+
return false;
35+
}
36+
37+
public void onEnable() {
38+
this.log.info(getDescription().getName() + " version " + getDescription().getVersion() + " started.");
39+
PluginManager pm = getServer().getPluginManager();
40+
pm.registerEvents(this.VehicleListener, (Plugin)this);
41+
pm.registerEvents(this.SignListener, (Plugin)this);
42+
}
43+
44+
public void onDisable() {
45+
this.log.info(getDescription().getName() + " version " + getDescription().getVersion() + " stopped.");
46+
}
47+
48+
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
49+
if (cmd.getName().equalsIgnoreCase("msp")) {
50+
if (sender instanceof Player) {
51+
Player player = (Player)sender;
52+
if (!player.hasPermission("msp.cmd")) {
53+
player.sendMessage("You don't have permission to do that");
54+
return true;
55+
}
56+
}
57+
try {
58+
this.multiplier = Double.parseDouble(args[0]);
59+
} catch (Exception e) {
60+
sender.sendMessage(ChatColor.YELLOW + "should be a number");
61+
return false;
62+
}
63+
this.result = setSpeedMultiplier(this.multiplier);
64+
if (this.result) {
65+
sender.sendMessage(ChatColor.YELLOW + "multiplier for new Minecarts set to: + this.multiplier);
66+
return true;
67+
}
68+
sender.sendMessage(ChatColor.YELLOW + "can not be set to zero and must be below");
69+
return true;
70+
}
71+
return false;
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package fi.dy.esav.Minecart_speedplus;
2+
3+
import org.bukkit.event.EventHandler;
4+
import org.bukkit.event.EventPriority;
5+
import org.bukkit.event.Listener;
6+
import org.bukkit.event.block.SignChangeEvent;
7+
8+
public class Minecart_speedplusSignListener implements Listener {
9+
10+
Minecart_speedplus plugin;
11+
12+
public Minecart_speedplusSignListener(Minecart_speedplus instance) {
13+
14+
plugin = instance;
15+
}
16+
17+
@EventHandler(priority = EventPriority.NORMAL)
18+
public void onSignChange (SignChangeEvent e) {
19+
if(e.getLine(0).equalsIgnoreCase("[msp]")){
20+
if(e.getLine(1).equalsIgnoreCase("fly") || e.getLine(1).equalsIgnoreCase("nofly")){
21+
if(!(e.getPlayer().hasPermission("msp.signs.fly"))) {
22+
e.setLine(0, "NO PERMS");
23+
}
24+
} else {
25+
boolean error = false;
26+
double speed = -1;
27+
28+
try {
29+
speed = Double.parseDouble(e.getLine(1));
30+
} catch (Exception ex) {
31+
error = true;
32+
}
33+
34+
if (error || 50 < speed || speed < 0) {
35+
e.setLine(1, "WRONG VALUE");
36+
}
37+
38+
if(!(e.getPlayer().hasPermission("msp.signs.speed"))) {
39+
e.setLine(0, "NO PERMS");
40+
}
41+
42+
}
43+
44+
45+
}
46+
47+
}
48+
49+
50+
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package fi.dy.esav.Minecart_speedplus;
2+
3+
import java.util.logging.Logger;
4+
5+
import org.bukkit.Material;
6+
import org.bukkit.block.Block;
7+
import org.bukkit.block.Sign;
8+
import org.bukkit.entity.Minecart;
9+
import org.bukkit.event.EventHandler;
10+
import org.bukkit.event.EventPriority;
11+
import org.bukkit.event.Listener;
12+
import org.bukkit.event.vehicle.VehicleCreateEvent;
13+
import org.bukkit.event.vehicle.VehicleMoveEvent;
14+
import org.bukkit.util.Vector;
15+
16+
public class Minecart_speedplusVehicleListener implements Listener {
17+
18+
int[] xmodifier = { -1, 0, 1 };
19+
int[] ymodifier = { -2, -1, 0, 1, 2 };
20+
int[] zmodifier = { -1, 0, 1 };
21+
22+
int cartx, carty, cartz;
23+
int blockx, blocky, blockz;
24+
25+
Block block;
26+
int blockid;
27+
28+
double line1;
29+
30+
public static Minecart_speedplus plugin;
31+
Logger log = Logger.getLogger("Minecraft");
32+
33+
boolean error;
34+
35+
Vector flyingmod = new Vector(10 , 0.01 , 10);
36+
Vector noflyingmod = new Vector(1, 1, 1);
37+
38+
public Minecart_speedplusVehicleListener(Minecart_speedplus instance) {
39+
plugin = instance;
40+
}
41+
42+
@EventHandler(priority = EventPriority.NORMAL)
43+
public void onVehicleCreate(VehicleCreateEvent event) {
44+
if (event.getVehicle() instanceof Minecart) {
45+
46+
Minecart cart = (Minecart) event.getVehicle();
47+
cart.setMaxSpeed(0.4 * Minecart_speedplus.getSpeedMultiplier());
48+
49+
}
50+
}
51+
52+
@EventHandler(priority = EventPriority.NORMAL)
53+
public void onVehicleMove(VehicleMoveEvent event) {
54+
55+
if (event.getVehicle() instanceof Minecart) {
56+
57+
Minecart cart = (Minecart) event.getVehicle();
58+
for (int xmod : xmodifier) {
59+
for (int ymod : ymodifier) {
60+
for (int zmod : zmodifier) {
61+
62+
cartx = cart.getLocation().getBlockX();
63+
carty = cart.getLocation().getBlockY();
64+
cartz = cart.getLocation().getBlockZ();
65+
blockx = cartx + xmod;
66+
blocky = carty + ymod;
67+
blockz = cartz + zmod;
68+
block = cart.getWorld().getBlockAt(blockx, blocky,
69+
blockz);
70+
blockid = cart.getWorld().getBlockTypeIdAt(blockx,
71+
blocky, blockz);
72+
73+
if (blockid == Material.WALL_SIGN.getId()
74+
|| blockid == Material.SIGN_POST.getId()) {
75+
Sign sign = (Sign) block.getState();
76+
String[] text = sign.getLines();
77+
78+
if (text[0].equalsIgnoreCase("[msp]")) {
79+
80+
if (text[1].equalsIgnoreCase("fly")) {
81+
cart.setFlyingVelocityMod(flyingmod);
82+
83+
} else if (text[1].equalsIgnoreCase("nofly")) {
84+
85+
cart.setFlyingVelocityMod(noflyingmod);
86+
87+
} else {
88+
89+
error = false;
90+
try {
91+
92+
line1 = Double.parseDouble(text[1]);
93+
94+
} catch (Exception e) {
95+
96+
sign.setLine(2, " ERROR");
97+
sign.setLine(3, "WRONG VALUE");
98+
sign.update();
99+
error = true;
100+
101+
}
102+
if (!error) {
103+
104+
if (0 < line1 & line1 <= 50) {
105+
106+
cart.setMaxSpeed(0.4D * Double.parseDouble(text[1]));
107+
108+
} else {
109+
110+
sign.setLine(2, " ERROR");
111+
sign.setLine(3, "WRONG VALUE");
112+
sign.update();
113+
}
114+
}
115+
}
116+
}
117+
118+
}
119+
120+
}
121+
}
122+
}
123+
124+
}
125+
}
126+
127+
}

src/main/resources/plugin.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: MinecartSpeedPlus
2+
main: fi.dy.esav.Minecart_speedplus.Minecart_speedplus
3+
version: 18.0.1
4+
commands:
5+
msp:
6+
description: Sets new minecart speed limit.
7+
usage: |
8+
"/msp <multiplier>" #limet = 4
9+
permissions:
10+
msp.*:
11+
description: Gives access to all msp features
12+
default: op
13+
children:
14+
msp.cmd: true
15+
msp.signs: true
16+
msp.cmd:
17+
description: Allows you to use speed cmd
18+
default: op
19+
msp.signs:
20+
description: Allows you to create both signs #limet = 4
21+
default: op
22+
children:
23+
msp.signs.speed: true
24+
msp.signs.fly: true
25+
msp.signs.speed:
26+
description: Allows you to create speed-sings #limet = 4
27+
default: op
28+
msp.signs.fly:
29+
description: Allows you to create fly-signs
30+
default: op

0 commit comments

Comments
 (0)