<commit_before>package com.ofallonminecraft.moarTP;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashSet;
import org.bukkit.command.CommandSender;
import com.ofallonminecraft.SpellChecker.SpellChecker;

public class Describe {

  public static boolean describe(CommandSender sender, String[] args, Connection c) {

    // check number of arguments
    if (args.length < 1) {
      sender.sendMessage("Must enter a location name and a description!");
      return false;
    } else if (args.length < 2) {
      sender.sendMessage("Must enter a description for the location!");
      return false;
    } else {
      if (!(args[1].startsWith("\"") && args[args.length-1].endsWith("\""))) {
        sender.sendMessage("Location name or description not formatted correctly!");
        return false;
      } 
    }

    // check if user is the creator of the location
    boolean isCreator = false;
    try {
      PreparedStatement s = c.prepareStatement("select creator from moarTP where location=?;");
      s.setString(1, args[0].toLowerCase());
      ResultSet creatorName = s.executeQuery();
      if (creatorName.next() && 
          creatorName.getString(1)!=null &&
          !creatorName.getString(1).equals("null") &&
          creatorName.getString(1).equals(sender.getName())) isCreator = true;
      creatorName.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    // check user permissions
    if (sender.isOp() || isCreator) {

      // ----- DESCRIBE ----- //
      try {
        PreparedStatement s = c.prepareStatement("select location from moarTP where location=?;");
        s.setString(1, args[0].toLowerCase());
        String description = "";
        for (int i=1; i<args.length; ++i) {
          description += args[i] + ' ';
        }
        description = description.substring(1,description.length()-2 );
        ResultSet rs = s.executeQuery();
        if (!rs.next()) {
          sender.sendMessage(args[0].toLowerCase()+" is not in the library!");
          HashSet<String> dict_subs = new HashSet<String>();
          dict_subs.add(SpellChecker.LOCATIONS);
          String sug = new SpellChecker(c, dict_subs).getSuggestion(args[0].toLowerCase());
          if (sug != null) {
            sender.sendMessage("Did you mean '/describe " + sug + "\"" + description + "\"'?");
          }
        } else {
          PreparedStatement ps = c.prepareStatement("update moarTP change info=? where location=?;");<commit_msg>Fixed a minor SQL error in /describe.<commit_after>package com.ofallonminecraft.moarTP;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashSet;
import org.bukkit.command.CommandSender;
import com.ofallonminecraft.SpellChecker.SpellChecker;

public class Describe {

  public static boolean describe(CommandSender sender, String[] args, Connection c) {

    // check number of arguments
    if (args.length < 1) {
      sender.sendMessage("Must enter a location name and a description!");
      return false;
    } else if (args.length < 2) {
      sender.sendMessage("Must enter a description for the location!");
      return false;
    } else {
      if (!(args[1].startsWith("\"") && args[args.length-1].endsWith("\""))) {
        sender.sendMessage("Location name or description not formatted correctly!");
        return false;
      } 
    }

    // check if user is the creator of the location
    boolean isCreator = false;
    try {
      PreparedStatement s = c.prepareStatement("select creator from moarTP where location=?;");
      s.setString(1, args[0].toLowerCase());
      ResultSet creatorName = s.executeQuery();
      if (creatorName.next() && 
          creatorName.getString(1)!=null &&
          !creatorName.getString(1).equals("null") &&
          creatorName.getString(1).equals(sender.getName())) isCreator = true;
      creatorName.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    // check user permissions
    if (sender.isOp() || isCreator) {

      // ----- DESCRIBE ----- //
      try {
        PreparedStatement s = c.prepareStatement("select location from moarTP where location=?;");
        s.setString(1, args[0].toLowerCase());
        String description = "";
        for (int i=1; i<args.length; ++i) {
          description += args[i] + ' ';
        }
        description = description.substring(1,description.length()-2 );
        ResultSet rs = s.executeQuery();
        if (!rs.next()) {
          sender.sendMessage(args[0].toLowerCase()+" is not in the library!");
          HashSet<String> dict_subs = new HashSet<String>();
          dict_subs.add(SpellChecker.LOCATIONS);
          String sug = new SpellChecker(c, dict_subs).getSuggestion(args[0].toLowerCase());
          if (sug != null) {
            sender.sendMessage("Did you mean '/describe " + sug + "\"" + description + "\"'?");
          }
        } else {
          PreparedStatement ps = c.prepareStatement("update moarTP set info=? where location=?;");
{'fraction_non_alphanumeric': 0.13939751919669227, 'fraction_numerical': 0.006300452845048238, 'mean_word_length': 2.765752409191994, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '671628', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1453, 'n_words': 355}