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