Archived
I drank a shit load of monster and pulled two all-nighters, I have no idea what all i did to be honest
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" build-on-make="true" name="PlayrimeRewards+ (Rewritten):jar">
|
||||||
|
<output-path>$PROJECT_DIR$/out/artifacts/PlayrimeRewards___Rewritten__jar</output-path>
|
||||||
|
<root id="archive" name="PlayrimeRewards+ (Rewritten).jar">
|
||||||
|
<element id="module-output" name="PlayrimeRewards+ (Rewritten)" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
Generated
+9
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DiscordProjectSettings">
|
||||||
|
<option name="show" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectNotificationSettings">
|
||||||
|
<option name="askShowProject" value="false" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+124
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -7,6 +7,18 @@
|
|||||||
<groupId>org.example</groupId>
|
<groupId>org.example</groupId>
|
||||||
<artifactId>PlayrimeRewards+ (Rewritten)</artifactId>
|
<artifactId>PlayrimeRewards+ (Rewritten)</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>6</source>
|
||||||
|
<target>6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<!-- This adds the Spigot Maven repository to the build -->
|
<!-- This adds the Spigot Maven repository to the build -->
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package dev.astridlabs.playtimerewardsplus.Commands;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandPlaytime implements CommandExecutor {
|
||||||
|
private Plugin plugin;
|
||||||
|
|
||||||
|
public CommandPlaytime(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||||
|
if(sender instanceof Player){
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix + "&aYour current playtime is: &7"+Integer.toString(plugin.db.getPlayer(player.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package dev.astridlabs.playtimerewardsplus.Commands;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandSeen implements CommandExecutor {
|
||||||
|
private Plugin plugin;
|
||||||
|
|
||||||
|
public CommandSeen(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||||
|
if(sender instanceof Player){
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
String pName = args[0];
|
||||||
|
Player mentioned = Bukkit.getPlayer(pName);
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&8--------&7 "+mentioned.getDisplayName()+" &8--------"));
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&aPlayers Playtime: &7"+Integer.toString(plugin.db.getPlayer(mentioned.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&aPlayers Logoff Location (X,Y,Z): &7"+plugin.config.getSavedX(mentioned.getUniqueId())+" "+plugin.config.getSavedY(mentioned.getUniqueId())+" "+plugin.config.getSavedZ(mentioned.getUniqueId())));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package dev.astridlabs.playtimerewardsplus.Commands;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Debug implements CommandExecutor {
|
||||||
|
private Plugin plugin;
|
||||||
|
private String DebugPrefix = "&7[&cDEBUG MODE&7] ";
|
||||||
|
|
||||||
|
public Debug(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||||
|
if(sender instanceof Player){
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(args[0].equals("time")){
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aUser playtime in seconds is: "+this.plugin.db.getPlayer(player.getUniqueId()).getPlaytime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[0].equals("location")){
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aLast player locaiton coordinates (X,Y,Z): "+this.plugin.db.getPlayer(player.getUniqueId()).getLastLocation().getX()+" "+this.plugin.db.getPlayer(player.getUniqueId()).getLastLocation().getY()+" "+this.plugin.db.getPlayer(player.getUniqueId()).getLastLocation().getZ()));
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aCurrent player locaiton coordinates (X,Y,Z): "+this.plugin.db.getPlayer(player.getUniqueId()).getCurrentLocation().getX()+" "+this.plugin.db.getPlayer(player.getUniqueId()).getCurrentLocation().getY()+" "+this.plugin.db.getPlayer(player.getUniqueId()).getCurrentLocation().getZ()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args[0].equals("location")){
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aForce dumping memory to disk, this could cause file corruption"));
|
||||||
|
plugin.config.savePlayers();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package dev.astridlabs.playtimerewardsplus.Controllers;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class ConfigController {
|
||||||
|
private Plugin plugin;
|
||||||
|
private File customConfigFile;
|
||||||
|
private FileConfiguration customConfig;
|
||||||
|
|
||||||
|
|
||||||
|
public ConfigController(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.customConfig = plugin.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void savePlayers(){
|
||||||
|
for (PlayerData player : plugin.db.playerList) {
|
||||||
|
customConfig.set("data."+player.getUuid()+".playtime", player.getPlaytime());
|
||||||
|
customConfig.set("data."+player.getUuid()+".displayName", player.getDisplayName());
|
||||||
|
customConfig.set("data."+player.getUuid()+".lastLocation.X", player.getCurrentLocation().getBlockX());
|
||||||
|
customConfig.set("data."+player.getUuid()+".lastLocation.Y", player.getCurrentLocation().getBlockY());
|
||||||
|
customConfig.set("data."+player.getUuid()+".lastLocation.Z", player.getCurrentLocation().getBlockZ());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
customConfig.save(customConfigFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
this.plugin.getServer().getLogger().log(Level.SEVERE, "ERROR OCCURED WHILE SAVING! DATA LOSS COULD OCCUR! ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// Custom Config Handler //
|
||||||
|
/////////////////////////////
|
||||||
|
public FileConfiguration getCustomConfig() {
|
||||||
|
return this.customConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createCustomConfig() throws IOException, InvalidConfigurationException {
|
||||||
|
customConfigFile = new File(plugin.getDataFolder(), "config.yml");
|
||||||
|
if (!customConfigFile.exists()) {
|
||||||
|
customConfigFile.getParentFile().mkdirs();
|
||||||
|
plugin.saveResource("config.yml", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
customConfig= new YamlConfiguration();
|
||||||
|
customConfig.load(customConfigFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSavedX(UUID uuid){
|
||||||
|
return this.customConfig.getString("data."+uuid.toString()+"lastLocation.X");
|
||||||
|
}
|
||||||
|
public String getSavedY(UUID uuid){
|
||||||
|
return this.customConfig.getString("data."+uuid.toString()+"lastLocation.Y");
|
||||||
|
}
|
||||||
|
public String getSavedZ(UUID uuid){
|
||||||
|
return this.customConfig.getString("data."+uuid.toString()+"lastLocation.Z");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// GASM.java (General Activation Sequence Manager)
|
|
||||||
// - In charge of making sure things do their thing when they are supposed to
|
|
||||||
//
|
|
||||||
// (c) Owen Rummage 2020
|
|
||||||
|
|
||||||
package dev.astridlabs.playtimerewardsplus.Controllers;
|
|
||||||
|
|
||||||
public class GASM {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
package dev.astridlabs.playtimerewardsplus.Controllers;
|
package dev.astridlabs.playtimerewardsplus.Controllers;
|
||||||
|
|
||||||
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -13,8 +14,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public class PlayerDatabase {
|
public class PlayerDatabase {
|
||||||
public List<PlayerData> playerList = new ArrayList<PlayerData>();
|
public List<PlayerData> playerList = new ArrayList<PlayerData>();
|
||||||
|
public Plugin plugin;
|
||||||
|
|
||||||
|
public PlayerDatabase(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PlayerData getPlayer(UUID uuid){
|
public PlayerData getPlayer(UUID uuid){
|
||||||
PlayerData returnedPlayer = null;
|
PlayerData returnedPlayer = null;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package dev.astridlabs.playtimerewardsplus.Events;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
public class PlayerJoin implements Listener {
|
||||||
|
|
||||||
|
public Plugin plugin;
|
||||||
|
|
||||||
|
public PlayerJoin(Plugin pl){
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
event.setJoinMessage("Welcome, " + event.getPlayer().getName() + "!");
|
||||||
|
plugin.db.createPlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
// PlaceholderAPIIntegration.java
|
||||||
|
// - Send data to PlaceholderAPI for other plugins to use
|
||||||
|
//
|
||||||
|
// (c) Owen Rummage 2020
|
||||||
|
package dev.astridlabs.playtimerewardsplus.Integrations;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class PlaceholderAPIIntegration extends PlaceholderExpansion {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The identifier, shouldn't contain any _ or %
|
||||||
|
*/
|
||||||
|
private Plugin plugin;
|
||||||
|
|
||||||
|
public PlaceholderAPIIntegration(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean persist(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean canRegister(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getAuthor(){
|
||||||
|
return "O_dude";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getIdentifier(){
|
||||||
|
return "playtimerewards";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getVersion(){
|
||||||
|
return plugin.getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String onPlaceholderRequest(Player player, String identifier) {
|
||||||
|
|
||||||
|
// We check if the player is null (not online) before any player-related placeholder
|
||||||
|
if(player == null){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Placeholder: %playtimerewards_prefix%
|
||||||
|
if(identifier.equals("prefix")) {
|
||||||
|
return plugin.PlaceholderChatPrefix.replace("%time%", "&a"+ Integer.toString(plugin.db.getPlayer(player.getUniqueId()).getPlaytime()/3600)+"&7h");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(identifier.equals("playtime")) {
|
||||||
|
return Integer.toString(plugin.db.getPlayer(player.getUniqueId()).getPlaytime());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(identifier.equals("lastloc_x")) {
|
||||||
|
return Double.toString(plugin.db.getPlayer(player.getUniqueId()).getLastLocation().getX());
|
||||||
|
}
|
||||||
|
if(identifier.equals("lastloc_y")) {
|
||||||
|
return Double.toString(plugin.db.getPlayer(player.getUniqueId()).getLastLocation().getY());
|
||||||
|
}
|
||||||
|
if(identifier.equals("lastloc_z")) {
|
||||||
|
return Double.toString(plugin.db.getPlayer(player.getUniqueId()).getLastLocation().getZ());
|
||||||
|
}
|
||||||
|
if(identifier.equals("curloc_x")) {
|
||||||
|
return Double.toString(plugin.db.getPlayer(player.getUniqueId()).getCurrentLocation().getX());
|
||||||
|
}
|
||||||
|
if(identifier.equals("curloc_y")) {
|
||||||
|
return Double.toString(plugin.db.getPlayer(player.getUniqueId()).getCurrentLocation().getY());
|
||||||
|
}
|
||||||
|
if(identifier.equals("curloc_z")) {
|
||||||
|
return Double.toString(plugin.db.getPlayer(player.getUniqueId()).getCurrentLocation().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// We return null, if an invalid placeholder was called.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package dev.astridlabs.playtimerewardsplus;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class MasterClock extends BukkitRunnable {
|
||||||
|
private final Plugin plugin;
|
||||||
|
private Integer clockTicks = 0;
|
||||||
|
|
||||||
|
public MasterClock(Plugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
clockTicks++;
|
||||||
|
|
||||||
|
if((clockTicks/72000) > 1){
|
||||||
|
this.plugin.config.savePlayers();
|
||||||
|
this.plugin.getServer().getLogger().log(Level.INFO, "Hourly save completed! Data loss avoided");
|
||||||
|
}
|
||||||
|
|
||||||
|
// What you want to schedule goes here
|
||||||
|
for(Player p : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
updatePlaytime(p);
|
||||||
|
updatePlayerLocations(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePlaytime(Player pl){
|
||||||
|
PlayerData player = plugin.db.getPlayer(pl.getUniqueId());
|
||||||
|
Integer playtime = player.getPlaytime();
|
||||||
|
Integer newplaytime = playtime+1;
|
||||||
|
player.setPlaytime(newplaytime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePlayerLocations(Player pl){
|
||||||
|
PlayerData player = plugin.db.getPlayer(pl.getUniqueId());
|
||||||
|
|
||||||
|
if(player.getCurrentLocation() == null){
|
||||||
|
player.setCurrentLocation(pl.getLocation());
|
||||||
|
}else{
|
||||||
|
player.setLastLocation(player.getCurrentLocation());
|
||||||
|
player.setCurrentLocation(pl.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,66 @@
|
|||||||
package dev.astridlabs.playtimerewardsplus;
|
package dev.astridlabs.playtimerewardsplus;
|
||||||
|
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Commands.CommandPlaytime;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Commands.CommandSeen;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Commands.Debug;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Controllers.ConfigController;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Controllers.PlayerDatabase;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Events.PlayerJoin;
|
||||||
|
import dev.astridlabs.playtimerewardsplus.Integrations.PlaceholderAPIIntegration;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Plugin extends JavaPlugin {
|
public class Plugin extends JavaPlugin {
|
||||||
|
|
||||||
|
//Initialize Everything
|
||||||
|
public PlayerDatabase db = new PlayerDatabase(this);
|
||||||
|
public BukkitScheduler scheduler = getServer().getScheduler();
|
||||||
|
public ConfigController config = new ConfigController(this);
|
||||||
|
|
||||||
|
//Config
|
||||||
|
public String PluginChatPrefix;
|
||||||
|
public String PlaceholderChatPrefix;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable(){
|
public void onEnable(){
|
||||||
|
//Get the clock running
|
||||||
|
new MasterClock(this).runTaskTimer(this, 0L, 20L);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
config.createCustomConfig();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Failed to createCustomConfig");
|
||||||
|
} catch (InvalidConfigurationException e) {
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Failed to createCustomConfig");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PlaceholderChatPrefix = getConfig().getString("Config.PlaceholderChatPrefix")+" ";
|
||||||
|
PluginChatPrefix = getConfig().getString("Config.PluginChatPrefix")+" ";
|
||||||
|
//Initialize Events
|
||||||
|
Bukkit.getPluginManager().registerEvents(new PlayerJoin(this), this); // This fires the event and allows any listener to listen to the event
|
||||||
|
|
||||||
|
//Only initialize if PlaceholderAPI is actually installed
|
||||||
|
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
|
new PlaceholderAPIIntegration(this).register();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Initialize Commands
|
||||||
|
this.getCommand("pt").setExecutor(new CommandPlaytime(this));
|
||||||
|
this.getCommand("ptdebug").setExecutor(new Debug(this));
|
||||||
|
this.getCommand("ptseen").setExecutor(new CommandSeen(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable(){
|
public void onDisable(){
|
||||||
|
config.savePlayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PlayerData {
|
public class PlayerData {
|
||||||
|
|
||||||
private Integer Playtime;
|
private int Playtime = 0;
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private String DisplayName;
|
private String DisplayName;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Config:
|
||||||
|
PluginChatPrefix: "&7[&6PTRR+&7]"
|
||||||
|
PlaceholderChatPrefix: "&8[%time%&8]&f"
|
||||||
|
|
||||||
|
data: {}
|
||||||
@@ -1,5 +1,17 @@
|
|||||||
name: PlaytimeRewards+(Rewritten)
|
main: dev.astridlabs.playtimerewardsplus.Plugin
|
||||||
|
name: PlaytimeRewardsRewrittenPlus
|
||||||
author: Astrid (O_dude)
|
author: Astrid (O_dude)
|
||||||
version: 0.1
|
version: 0.1a
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
pt:
|
||||||
|
description: This command shows your current playtime
|
||||||
|
usage: /pt
|
||||||
|
ptdebug:
|
||||||
|
description: This is a debug command for debugging stuff
|
||||||
|
usage: /ptdebug
|
||||||
|
ptseen:
|
||||||
|
description: Get information about a player
|
||||||
|
usage: /ptseen
|
||||||
|
|
||||||
|
softdepend: [PlaceholderAPI] # This is used, if your plugin works without PlaceholderAPI.
|
||||||
|
|||||||
Reference in New Issue
Block a user