mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-10-31 21:47:10 +00:00
Fixes FS-323 by rewriting ride modes to make sense
This commit is contained in:
parent
459a11e638
commit
af710edc88
@ -84,19 +84,22 @@ public class Command_ride extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 2)
|
||||
if (args.length >= 2 && args[0].equalsIgnoreCase("mode"))
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("mode"))
|
||||
try
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("normal") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("ask"))
|
||||
{
|
||||
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
||||
playerDataSender.setRideMode(args[1].toLowerCase());
|
||||
plugin.pl.save(playerDataSender);
|
||||
msg("Ride mode is now set to " + args[1].toLowerCase() + ".");
|
||||
return true;
|
||||
}
|
||||
PlayerData.RideMode mode = PlayerData.RideMode.valueOf(args[1].toUpperCase());
|
||||
PlayerData playerDataSender = plugin.pl.getData(playerSender);
|
||||
playerDataSender.setRideMode(mode);
|
||||
plugin.pl.save(playerDataSender);
|
||||
msg("Ride mode is now set to " + mode.name().toLowerCase() + ".");
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
msg("Invalid mode.", ChatColor.RED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0], true);
|
||||
@ -114,13 +117,13 @@ public class Command_ride extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerData.getRideMode().equals("off") && !isAdmin(sender))
|
||||
if (playerData.getRideMode() == PlayerData.RideMode.OFF && !isAdmin(sender))
|
||||
{
|
||||
msg("That player cannot be ridden.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
|
||||
if (playerData.getRideMode() == PlayerData.RideMode.ASK && !FUtil.isExecutive(playerSender.getName()))
|
||||
{
|
||||
msg("Sent a request to the player.", ChatColor.GREEN);
|
||||
msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA);
|
||||
|
@ -23,7 +23,7 @@ public class PlayerData
|
||||
private Boolean masterBuilder = false;
|
||||
|
||||
|
||||
private String rideMode = "ask";
|
||||
private RideMode rideMode = RideMode.ASK;
|
||||
|
||||
|
||||
private int coins;
|
||||
@ -51,7 +51,7 @@ public class PlayerData
|
||||
tag = resultSet.getString("tag");
|
||||
discordID = resultSet.getString("discord_id");
|
||||
masterBuilder = resultSet.getBoolean("master_builder");
|
||||
rideMode = resultSet.getString("ride_mode");
|
||||
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
|
||||
coins = resultSet.getInt("coins");
|
||||
items.clear();
|
||||
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
||||
@ -82,7 +82,7 @@ public class PlayerData
|
||||
"- Total Votes: " + totalVotes + "\n" +
|
||||
"- Display Discord: " + displayDiscord + "\n" +
|
||||
"- Tag: " + FUtil.colorize(tag) + ChatColor.GRAY + "\n" +
|
||||
"- Ride Mode: " + rideMode + "\n" +
|
||||
"- Ride Mode: " + rideMode.name() + "\n" +
|
||||
"- Login Message: " + loginMessage;
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ public class PlayerData
|
||||
put("tag", tag);
|
||||
put("discord_id", discordID);
|
||||
put("master_builder", masterBuilder);
|
||||
put("ride_mode", rideMode);
|
||||
put("ride_mode", rideMode.name());
|
||||
put("coins", coins);
|
||||
put("items", FUtil.listToString(items));
|
||||
put("total_votes", totalVotes);
|
||||
@ -249,12 +249,12 @@ public class PlayerData
|
||||
this.masterBuilder = masterBuilder;
|
||||
}
|
||||
|
||||
public String getRideMode()
|
||||
public RideMode getRideMode()
|
||||
{
|
||||
return rideMode;
|
||||
}
|
||||
|
||||
public void setRideMode(String rideMode)
|
||||
public void setRideMode(RideMode rideMode)
|
||||
{
|
||||
this.rideMode = rideMode;
|
||||
}
|
||||
@ -308,4 +308,11 @@ public class PlayerData
|
||||
{
|
||||
this.inspect = inspect;
|
||||
}
|
||||
|
||||
public enum RideMode
|
||||
{
|
||||
ASK,
|
||||
NORMAL,
|
||||
OFF
|
||||
}
|
||||
}
|
@ -249,7 +249,7 @@ public class SQLite extends FreedomService
|
||||
statement.setString(4, player.getTag());
|
||||
statement.setString(5, player.getDiscordID());
|
||||
statement.setBoolean(6, player.isMasterBuilder());
|
||||
statement.setString(7, player.getRideMode());
|
||||
statement.setString(7, player.getRideMode().name());
|
||||
statement.setInt(8, player.getCoins());
|
||||
statement.setString(9, FUtil.listToString(player.getItems()));
|
||||
statement.setInt(10, player.getTotalVotes());
|
||||
|
Loading…
Reference in New Issue
Block a user