Last active
February 26, 2016 08:13
-
-
Save cFerg/f576488386302c3b771b to your computer and use it in GitHub Desktop.
ISaid.jar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package elite; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashMap; | |
import java.util.List; | |
import org.bukkit.entity.Player; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class ChatAPI extends JavaPlugin{ | |
//String is used in place of uuid | |
//Replace message 'after' the usage check | |
//Stores the 'last' messaged typed (per user) | |
HashMap<String, String> PreviousMessage = new HashMap<>(); | |
//Stores only the 'last' message typed (period) | |
HashMap<String, String> RecentMessage = new HashMap<>(); | |
public static boolean dupeCheckAll(Player player, String message){ | |
return false; | |
} | |
public static boolean dupeCheckPlayer(Player player, String message){ | |
return false; | |
} | |
//========================================================== | |
//========================================================== | |
//Individual message checks | |
//========================================================== | |
//========================================================== | |
//========================================================== | |
//Count Methods | |
//========================================================== | |
//Returns number of numbers in a string | |
public static int countNumbers(String message){ | |
return (message.replaceAll("[^0-9]", "").toCharArray().length); | |
} | |
//========================================================== | |
//Has <blank> Methods | |
//========================================================== | |
//Checks if the message has any numbers | |
public static boolean hasNumbers(String message){ | |
return false; | |
} | |
//========================================================== | |
//Is <blank> Methods | |
//========================================================== | |
//Checks if the message is all camel case | |
public static boolean isAllCamelCase(String message, Boolean fullCamel){ | |
int allCamel = 0; | |
int wordCount = 0; | |
boolean halt = false; | |
while (halt == false){ | |
if (fullCamel == true){ | |
for (String split : message.split("\\s+")){ | |
wordCount = wordCount + 1; | |
Boolean secondLower = false; | |
Boolean restLower = false; | |
char[] charLetter = split.toCharArray(); | |
int charSize = charLetter.length; | |
//Get first letter | |
String firstLetter = String.valueOf(charLetter[0]); | |
Boolean firstCap = firstLetter.equals(firstLetter.toUpperCase()); | |
//Get second letter | |
if (charSize > 1){ | |
String secondLetter = String.valueOf(charLetter[1]); | |
secondLower = secondLetter.equals(secondLetter.toLowerCase()); | |
} | |
//Get the rest of the letters | |
if (charSize > 2){ | |
Boolean temp = true; | |
while (temp == true){ | |
for (int i = 2; i < charSize; i++){ | |
String currentLetter = String.valueOf(charLetter[i]); | |
temp = currentLetter.equals(currentLetter.toLowerCase()); | |
} | |
} | |
restLower = temp; | |
} | |
//Check if the word is full camel or not | |
if (charSize == 1){ | |
if ((firstCap == true)){ | |
allCamel = allCamel + 1; | |
}else{ | |
halt = true; | |
} | |
}else if (charSize == 2){ | |
if ((firstCap == true) && (secondLower == true)){ | |
allCamel = allCamel + 1; | |
}else{ | |
halt = true; | |
} | |
}else if (charSize > 2){ | |
if ((firstCap == true) && (secondLower == true) && (restLower == true)){ | |
allCamel = allCamel + 1; | |
}else{ | |
halt = true; | |
} | |
} | |
} | |
}else{ | |
for (String split : message.split("\\s+")){ | |
wordCount = wordCount + 1; | |
Boolean secondLower = false; | |
char[] charLetter = split.toCharArray(); | |
int charSize = charLetter.length; | |
//Get first letter | |
String firstLetter = String.valueOf(charLetter[0]); | |
Boolean firstCap = firstLetter.equals(firstLetter.toUpperCase()); | |
//Get second letter | |
if (charSize > 1){ | |
String secondLetter = String.valueOf(charLetter[1]); | |
secondLower = secondLetter.equals(secondLetter.toLowerCase()); | |
} | |
//Check if the word is full camel or not | |
if (charSize == 1){ | |
if ((firstCap == true)){ | |
allCamel = allCamel + 1; | |
}else{ | |
halt = true; | |
} | |
}else if (charSize >= 2){ | |
if ((firstCap == true) && (secondLower == true)){ | |
allCamel = allCamel + 1; | |
}else{ | |
halt = true; | |
} | |
} | |
} | |
} | |
} | |
if (halt == true){ | |
return false; | |
}else{ | |
return (allCamel == wordCount); | |
} | |
} | |
//Checks if the message is all caps | |
public static boolean isAllCaps(String message){ | |
String originalMessage = message; | |
return originalMessage.equals(message.toUpperCase()); | |
} | |
//Checks if the amount of characters is the same before and after checking for numbers | |
public static boolean isAllNumbers(String message){ | |
return (message.toCharArray().length == message.replaceAll("[^0-9.]", "").toCharArray().length); | |
} | |
public static boolean isAllSymbols(String message){ | |
return false; | |
} | |
public static boolean isSpammingCharacters(String message, int characterLimit){ | |
return false; | |
} | |
public static boolean isSpammingCommands(String message, int commandLimit){ | |
Boolean commandDupe = false; | |
List<String> CurrentMessage = new ArrayList<>(); | |
CurrentMessage.addAll(Arrays.asList(message.split("\\s+"))); | |
for (String split : message.split("\\s+")){ | |
if (split.contains("/") || split.contains("//")){ | |
} | |
} | |
return false; | |
} | |
public static boolean isSpammingLetters(String message, int characterLimit){ | |
return false; | |
} | |
//========================================================== | |
//To <blank> Methods | |
//========================================================== | |
public static String toCamelCase(String message){ | |
String newMessage = ""; | |
for (String split : message.split("\\s+")){ | |
split = split.toLowerCase(); | |
char[] charLetter = split.toCharArray(); | |
split = split.replaceFirst(String.valueOf(charLetter[0]), String.valueOf(charLetter[0]).toUpperCase()); | |
newMessage = newMessage.concat(split + " "); | |
} | |
return newMessage.trim(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment