Add velocity toggle for mod+
This commit is contained in:
parent
7892c442d0
commit
92f8dc7f61
@ -15,10 +15,10 @@ import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class PreferencesRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports FROM accountPreferences WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ? WHERE uuid=?;";
|
||||
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity FROM accountPreferences WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ? WHERE uuid=?;";
|
||||
|
||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||
{
|
||||
@ -55,7 +55,8 @@ public class PreferencesRepository extends RepositoryBase
|
||||
preparedStatement.setBoolean(7, entry.getValue().Invisibility);
|
||||
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
|
||||
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
||||
preparedStatement.setString(10, entry.getKey());
|
||||
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
||||
preparedStatement.setString(11, entry.getKey());
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
@ -105,6 +106,7 @@ public class PreferencesRepository extends RepositoryBase
|
||||
preferences.Invisibility = resultSet.getBoolean(7);
|
||||
preferences.HubForcefield = resultSet.getBoolean(8);
|
||||
preferences.ShowMacReports = resultSet.getBoolean(9);
|
||||
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
|
@ -12,4 +12,5 @@ public class UserPreferences
|
||||
public boolean Invisibility = false;
|
||||
public boolean HubForcefield = false;
|
||||
public boolean ShowMacReports = false;
|
||||
public boolean IgnoreVelocity = false;
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
private IButton _toggleHubPartyRequests;
|
||||
private IButton _toggleHubInvisibility;
|
||||
private IButton _toggleHubForcefield;
|
||||
private IButton _toggleHubIgnoreVelocity;
|
||||
private IButton _toggleMacReports;
|
||||
|
||||
|
||||
private boolean _hubGamesToggled;
|
||||
private boolean _hubPlayersToggled;
|
||||
private boolean _hubChatToggled;
|
||||
@ -32,6 +33,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
private boolean _hubInvisibilityToggled;
|
||||
private boolean _hubForcefieldToggled;
|
||||
private boolean _macReportsToggled;
|
||||
private boolean _hubIgnoreVelocityToggled;
|
||||
|
||||
public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
||||
{
|
||||
@ -162,6 +164,21 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
toggleMacReports(player);
|
||||
}
|
||||
};
|
||||
|
||||
_toggleHubIgnoreVelocity = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
toggleHubIgnoreVelocity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
toggleHubIgnoreVelocity(player);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void buildPreference(int index, Material material, String name, boolean preference, IButton button)
|
||||
@ -174,7 +191,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
String[] description = new String[] {
|
||||
"" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"),
|
||||
ChatColor.RED + " ",
|
||||
"Click to " + (preference ? "Disable" : "Enable") };
|
||||
ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") };
|
||||
|
||||
AddButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button);
|
||||
AddButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte)10 : (byte)8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button);
|
||||
@ -235,6 +252,13 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
_macReportsToggled = !_macReportsToggled;
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
protected void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
|
||||
{
|
||||
Plugin.Get(player).IgnoreVelocity = !Plugin.Get(player).IgnoreVelocity;
|
||||
_hubIgnoreVelocityToggled = !_hubIgnoreVelocityToggled;
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PlayerClosed()
|
||||
@ -254,7 +278,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
UserPreferences userPreferences = Plugin.Get(Player);
|
||||
int index = 18;
|
||||
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.ADMIN) || ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR) || ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
{
|
||||
index = 9;
|
||||
}
|
||||
@ -268,16 +292,23 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
buildPreference(index, Material.EMPTY_MAP, "Private Messaging", userPreferences.PrivateMessaging, _togglePrivateChat);
|
||||
index += 2;
|
||||
buildPreference(index, Material.SKULL_ITEM, (byte)3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests);
|
||||
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.ADMIN) || ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
|
||||
if (ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
{
|
||||
buildPreference(39, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||
buildPreference(41, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||
buildPreference(43, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
}
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.ADMIN))
|
||||
{
|
||||
buildPreference(37, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||
buildPreference(39, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||
buildPreference(41, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(43, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
}
|
||||
else if (ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR))
|
||||
{
|
||||
buildPreference(40, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(39, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(41, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -947,4 +948,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR) && _preferences.Get(event.getPlayer()).IgnoreVelocity)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user