Read description lol

- Re-added premium
- Made the clown fish a shop item
- Thank fuck I caught this DB bug with setting null values
This commit is contained in:
Seth 2020-07-09 15:18:29 -07:00
parent f6ee9271c6
commit c87e1b3d64
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3
15 changed files with 239 additions and 27 deletions

View File

@ -324,7 +324,7 @@ public class AdminList extends FreedomService
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
{
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null)
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
{
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
}

View File

@ -0,0 +1,29 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Obtain a clown fish", usage = "/<command>")
public class Command_clownfish extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH))
{
playerSender.getInventory().addItem(plugin.sh.getClownFish());
msg("You have been given a Clown Fish", ChatColor.GREEN);
}
else
{
msg("You do not own a Clown Fish! Purchase one from the shop.", ChatColor.RED);
}
return true;
}
}

View File

@ -0,0 +1,80 @@
package me.totalfreedom.totalfreedommod.command;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Adds or removes donators", usage = "/<command> <mode> <name> <ip> <package> [forum_user]")
public class Command_donator extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!FUtil.isFromHostConsole(sender.getName()) && !ConfigEntry.SERVER_OWNERS.getStringList().contains(sender.getName()))
{
return noPerms();
}
Boolean mode = args[0].equals("add");
String name = args[1];
String ip = args[2];
String pkg = args[3];
String forum_id = null;
if (args.length > 4)
{
forum_id = args[4];
}
PlayerData player = plugin.pl.getData(name);
if (player == null)
{
player = plugin.pl.getDataByIp(ip);
}
if (player != null)
{
player.setDonator(mode);
plugin.pl.save(player);
}
if (forum_id != null && !forum_id.equals("0"))
{
String baseurl = ConfigEntry.DONATION_PROBOARDS_URL.getString();
String group_id = ConfigEntry.DONATION_GROUP_ID.getString();
String session_id = ConfigEntry.DONATION_SESSION_ID.getString();
String csrf_token = ConfigEntry.DONATION_CSRF_TOKEN.getString();
if (baseurl == null || group_id == null || session_id == null || csrf_token == null)
{
return true;
}
String url = baseurl + "/user/group_members/" + (mode ? "adding" : "remove");
List<String> headers = Arrays.asList("Cookie:session_id=" + session_id, "X-Requested-With:XMLHttpRequest");
String payload = "group_id=" + group_id + "&user_ids[]=" + forum_id + "&csrf_token=" + csrf_token;
try
{
String result = FUtil.postRequestToEndpoint(url, "POST", headers, payload);
msg(result);
}
catch (IOException e)
{
FLog.severe(e.getMessage());
e.printStackTrace();
}
}
return true;
}
}

View File

@ -21,11 +21,12 @@ public class Command_tag extends FreedomCommand
public static final List<String> FORBIDDEN_WORDS = Arrays.asList(
"admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "tca", "sta", "sa");
public boolean save = false;
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean save = false;
if (args.length < 1)
{
return false;

View File

@ -83,6 +83,11 @@ public enum ConfigEntry
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
//
DONATION_PROBOARDS_URL(String.class, "donation.proboards_url"),
DONATION_GROUP_ID(String.class, "donation.donator_group_id"),
DONATION_SESSION_ID(String.class, "donation.session_id"),
DONATION_CSRF_TOKEN(String.class, "donation.csrf_token"),
//
SHOP_ENABLED(Boolean.class, "shop.enabled"),
SHOP_TITLE(String.class, "shop.title"),
SHOP_PREFIX(String.class, "shop.prefix"),
@ -97,6 +102,7 @@ public enum ConfigEntry
SHOP_PRICES_FIRE_BALL(Integer.class, "shop.prices.fire_ball"),
SHOP_PRICES_RIDEABLE_PEARL(Integer.class, "shop.prices.rideable_pearl"),
SHOP_PRICES_STACKING_POTATO(Integer.class, "shop.prices.stacking_potato"),
SHOP_PRICES_CLOWN_FISH(Integer.class, "shop.prices.clown_fish"),
//
ADMINLIST_CLEAN_THESHOLD_HOURS(Integer.class, "adminlist.clean_threshold_hours"),
ADMINLIST_CONSOLE_IS_SENIOR(Boolean.class, "adminlist.console_is_senior"),

View File

@ -11,6 +11,8 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
@ -232,7 +234,7 @@ public class ItemFun extends FreedomService
if (onCooldown(player, ShopItem.FIRE_BALL))
{
player.sendMessage(ChatColor.RED + "You're are currently on a cooldown for 5 seconds.");
player.sendMessage(ChatColor.RED + "You're are currently on a cool-down for 5 seconds.");
break;
}
@ -243,6 +245,67 @@ public class ItemFun extends FreedomService
cooldown(player, ShopItem.FIRE_BALL, 5);
break;
}
case TROPICAL_FISH:
{
final int RADIUS_HIT = 5;
final int STRENGTH = 4;
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.CLOWN_FISH, player.getInventory().getItemInMainHand(), plugin.sh.getClownFish()))
{
break;
}
if (onCooldown(player, ShopItem.CLOWN_FISH))
{
player.sendMessage(ChatColor.RED + "You're are currently on a cool-down for 30 seconds.");
break;
}
event.setCancelled(true);
boolean didHit = false;
final Location playerLoc = player.getLocation();
final Vector playerLocVec = playerLoc.toVector();
final List<Player> players = player.getWorld().getPlayers();
for (final Player target : players)
{
if (target == player)
{
continue;
}
final Location targetPos = target.getLocation();
final Vector targetPosVec = targetPos.toVector();
try
{
if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT))
{
FUtil.setFlying(player, false);
target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH));
didHit = true;
}
}
catch (IllegalArgumentException ex)
{
}
}
if (didHit)
{
final Sound[] sounds = Sound.values();
for (Sound sound : sounds)
{
if (sound.toString().contains("HIT"))
{
playerLoc.getWorld().playSound(randomOffset(playerLoc, 5.0), sound, 20f, randomDoubleRange(0.5, 2.0).floatValue());
}
}
cooldown(player, ShopItem.CLOWN_FISH, 30);
}
break;
}
}
}

View File

@ -32,6 +32,8 @@ public class PlayerData
private String discordID = null;
private final List<String> backupCodes = Lists.newArrayList();
@Setter
private boolean donator = false;
@Setter
private Boolean masterBuilder = false;
@Setter
private Boolean verification = false;
@ -207,6 +209,11 @@ public class PlayerData
return verification;
}
public boolean isDonator()
{
return donator;
}
public boolean isMasterBuilder()
{
return masterBuilder;
@ -222,6 +229,7 @@ public class PlayerData
put("tag", tag);
put("discord_id", discordID);
put("backup_codes", FUtil.listToString(backupCodes));
put("donator", masterBuilder);
put("master_builder", masterBuilder);
put("verification", verification);
put("ride_mode", rideMode);

View File

@ -225,7 +225,7 @@ public class PlayerList extends FreedomService
for (Map.Entry<String, Object> entry : player.toSQLStorable().entrySet())
{
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null)
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
{
plugin.sql.setPlayerValue(player, entry.getKey(), entry.getValue());
}

View File

@ -54,7 +54,7 @@ public enum Rank implements Displayable
@Override
public String getColoredLoginMessage()
{
return determiner + " " + color + ChatColor.ITALIC + name;
return determiner + " " + color + name;
}
@Override

View File

@ -77,6 +77,12 @@ public class RankManager extends FreedomService
return Title.MASTER_BUILDER;
}
PlayerData playerData = plugin.pl.getData(player);
if (!plugin.al.isAdmin(player) && playerData.isDonator())
{
return Title.DONATOR;
}
return getRank(player);
}
@ -173,7 +179,7 @@ public class RankManager extends FreedomService
FPlayer fPlayer = plugin.pl.getPlayer(player);
PlayerData data = plugin.pl.getData(player);
Displayable display = getDisplay(player);
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || FUtil.isDeveloper(player.getName()))
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || data.isDonator() || FUtil.isDeveloper(player.getName()))
{
String displayName = display.getColor() + player.getName();
player.setPlayerListName(displayName);
@ -241,7 +247,7 @@ public class RankManager extends FreedomService
}
// Set display
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.pl.getData(player).isMasterBuilder())
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.pl.getData(player).isMasterBuilder() || plugin.pl.getData(player).isDonator())
{
final Displayable display = getDisplay(player);

View File

@ -6,6 +6,7 @@ import net.md_5.bungee.api.ChatColor;
public enum Title implements Displayable
{
DONATOR("a", "Premium Member", ChatColor.of("#ff5600"), org.bukkit.ChatColor.LIGHT_PURPLE, "Premium", true),
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, org.bukkit.ChatColor.DARK_AQUA, "MB", true),
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, org.bukkit.ChatColor.LIGHT_PURPLE, "VA", false),
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Asst Exec", true),
@ -56,7 +57,7 @@ public enum Title implements Displayable
@Override
public String getColoredLoginMessage()
{
return determiner + " " + color + ChatColor.ITALIC + name;
return determiner + " " + color + name;
}
}

View File

@ -237,6 +237,15 @@ public class Shop extends FreedomService
return itemStack;
}
public ItemStack getClownFish()
{
ItemStack itemStack = new ItemStack(Material.TROPICAL_FISH);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD + "Clown Fish");
itemMeta.setLore(Arrays.asList(ChatColor.AQUA + ":clown:"));
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public boolean canAfford(int price, int coins)
{

View File

@ -11,17 +11,18 @@ public enum ShopItem
LIGHTNING_ROD("Lightning Rod", Material.BLAZE_ROD, 12, ConfigEntry.SHOP_PRICES_LIGHTNING_ROD, ChatColor.LIGHT_PURPLE, "lightningRod", "/lightningrod"),
FIRE_BALL("Fire Ball", Material.FIRE_CHARGE, 14, ConfigEntry.SHOP_PRICES_FIRE_BALL, ChatColor.RED, "fireBall", "/fireball"),
RIDEABLE_PEARL("Rideable Ender Pearl", Material.ENDER_PEARL, 16, ConfigEntry.SHOP_PRICES_RIDEABLE_PEARL, ChatColor.DARK_PURPLE, "rideablePearl", "/rideablepearl"),
STACKING_POTATO("Stacking Potato", Material.POTATO, 22, ConfigEntry.SHOP_PRICES_STACKING_POTATO, ChatColor.YELLOW, "stackingPotato", "/stackingpotato");
STACKING_POTATO("Stacking Potato", Material.POTATO, 20, ConfigEntry.SHOP_PRICES_STACKING_POTATO, ChatColor.YELLOW, "stackingPotato", "/stackingpotato"),
CLOWN_FISH("Clown Fish", Material.TROPICAL_FISH, 24, ConfigEntry.SHOP_PRICES_CLOWN_FISH, ChatColor.GOLD, "clownFish", "/clownfish");
/*
Shop GUI Layout:
Dimensions: 9x4 = 36
Key: g = Grappling Hook, l = Lightning Rod, f = Fire Ball, r = Rideable Ender Pearl, S = Stacking Potato $ = Coins}
Key: g = Grappling Hook, l = Lightning Rod, f = Fire Ball, r = Rideable Ender Pearl, s = Stacking Potato, c = Clown Fish, $ = Coins}
---------
-g-l-f-r-
----s----
--s---c--
--------$
*/

View File

@ -95,7 +95,7 @@ public class SQLite extends FreedomService
{
try
{
connection.createStatement().execute("CREATE TABLE `players` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `notes` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `backup_codes` VARCHAR, `master_builder` BOOLEAN NOT NULL,`verification` BOOLEAN NOT NULL, `ride_mode` VARCHAR NOT NULL, `coins` INT NOT NULL, `items` VARCHAR, `total_votes` INT NOT NULL);");
connection.createStatement().execute("CREATE TABLE `players` (`username` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `notes` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `backup_codes` VARCHAR, `donator` BOOLEAN NOT NULL, `master_builder` BOOLEAN NOT NULL,`verification` BOOLEAN NOT NULL, `ride_mode` VARCHAR NOT NULL, `coins` INT NOT NULL, `items` VARCHAR, `total_votes` INT NOT NULL);");
}
catch (SQLException e)
{
@ -153,7 +153,6 @@ public class SQLite extends FreedomService
{
Object[] data = {key, player.getName()};
PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE players SET {0}=? WHERE username=''{1}''", data));
FLog.info(statement.toString());
statement = setUnknownType(statement, 1, value);
statement.executeUpdate();
@ -196,7 +195,11 @@ public class SQLite extends FreedomService
public PreparedStatement setUnknownType(PreparedStatement statement, int index, Object value) throws SQLException
{
if (value.getClass().equals(String.class))
if (value == null)
{
statement.setString(index, null);
}
else if (value.getClass().equals(String.class))
{
String v = (String)value;
statement.setString(index, v);
@ -269,19 +272,20 @@ public class SQLite extends FreedomService
{
try
{
PreparedStatement statement = connection.prepareStatement("INSERT INTO players VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement statement = connection.prepareStatement("INSERT INTO players VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
statement.setString(1, player.getName());
statement.setString(2, FUtil.listToString(player.getIps()));
statement.setString(3, FUtil.listToString(player.getNotes()));
statement.setString(4, player.getTag());
statement.setString(5, player.getDiscordID());
statement.setString(6, FUtil.listToString(player.getBackupCodes()));
statement.setBoolean(7, player.isMasterBuilder());
statement.setBoolean(8, player.hasVerification());
statement.setString(9, player.getRideMode());
statement.setInt(10, player.getCoins());
statement.setString(11, FUtil.listToString(player.getItems()));
statement.setInt(12, player.getTotalVotes());
statement.setBoolean(7, player.isDonator());
statement.setBoolean(8, player.isMasterBuilder());
statement.setBoolean(9, player.hasVerification());
statement.setString(10, player.getRideMode());
statement.setInt(11, player.getCoins());
statement.setString(12, FUtil.listToString(player.getItems()));
statement.setInt(13, player.getTotalVotes());
statement.executeUpdate();
}
catch (SQLException e)

View File

@ -123,6 +123,7 @@ shop:
fire_ball: 500
rideable_pearl: 700
stacking_potato: 300
clown_fish: 1500
# Admin list
adminlist:
@ -159,6 +160,12 @@ social_links:
Website: 'https://totalfreedom.me/'
Discord: 'https://discordapp.com/invite/XXjmAmV/'
donation:
proboards_url: ''
donator_group_id: ''
session_id: ''
csrf_token: ''
# Blocking certain events
allow:
fire_place: false
@ -362,7 +369,6 @@ announcer:
announcements:
- 'Be sure to visit our forums at &6http://totalfreedom.boards.net/'
- 'You can always review the server rules here: &6http://totalfreedom.me/'
- 'If you are not OP, be sure to ask!'
- 'Somebody breaking the rules? Report it! /report <user> <reason>'
- 'Griefing is not allowed!'
@ -370,18 +376,16 @@ announcer:
- 'Interested in becoming admin? Type "/ai" for more information!'
- 'You may view all online administrators via "/list -a"'
- 'Save your buildings via WorldEdit! http://totalfreedom.me for more information!'
- 'Famous players, such as Notch, are always fake! We are an offline/cracked server!'
- 'You may contact TotalFreedom support on Twitter! https://tiny.re/tfsupport'
- 'You may download TotalFreedomMod here: https://tiny.re/tfm+'
- 'Catholic_Mario is the owner of TotalFreedom.'
- 'MarkByron is the founder of TotalFreedom.'
- 'scripthead is the owner of TotalFreedom.'
- 'markbyron is the founder of TotalFreedom.'
- 'Server lagging? Check the lag via "/tps"'
- 'You are allowed to record and stream videos on TotalFreedom.'
- 'Player vs player while in creative or god mode is forbidden!'
- 'Spawn killing is forbidden!'
- 'Invisible potions are allowed!'
- 'Serial griefing and trolling will result in a permanent ban!'
- 'TotalFreedom does not accept any form of donations!'
- 'Racism, nazism, and sexism are strictly forbidden!'
- 'Join our Discord server! Link: https://discordapp.com/invite/XXjmAmV/'