Fix #32, add bstats metrics
This commit is contained in:
parent
9beef25970
commit
277974edae
|
@ -106,4 +106,6 @@ modules.xml
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
|
.attach_*
|
||||||
|
|
||||||
# End of https://www.gitignore.io/api/java,intellij+iml
|
# End of https://www.gitignore.io/api/java,intellij+iml
|
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -42,8 +42,12 @@
|
||||||
<pattern>net.wesjd.anvilgui</pattern>
|
<pattern>net.wesjd.anvilgui</pattern>
|
||||||
<shadedPattern>net.seanomik.energeticstorage.anvilgui</shadedPattern>
|
<shadedPattern>net.seanomik.energeticstorage.anvilgui</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.bstats</pattern>
|
||||||
|
<shadedPattern>net.seanomik.energeticstorage.bstats</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
<outputFile>C:\Development\Java\Spigot Servers\${server.version}\plugins\EnergeticStorage-v${project.version}.jar</outputFile>
|
<outputFile>/home/seanomik/Development/java/spigot-dev/test-servers/${server.version}/plugins/EnergeticStorage-v${project.version}.jar</outputFile>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
13
pom.xml
13
pom.xml
|
@ -50,9 +50,14 @@
|
||||||
<pattern>net.wesjd.anvilgui</pattern>
|
<pattern>net.wesjd.anvilgui</pattern>
|
||||||
<shadedPattern>net.seanomik.energeticstorage.anvilgui</shadedPattern>
|
<shadedPattern>net.seanomik.energeticstorage.anvilgui</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.bstats</pattern>
|
||||||
|
<!-- Replace this with your package! -->
|
||||||
|
<shadedPattern>net.seanomik.energeticstorage.bstats</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
|
|
||||||
<outputFile>C:\Development\Java\Spigot Servers\${server.version}\plugins\EnergeticStorage-v${project.version}.jar</outputFile>
|
<outputFile>/home/seanomik/Development/java/spigot-dev/test-servers/${server.version}/plugins/EnergeticStorage-v${project.version}.jar</outputFile>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -132,5 +137,11 @@
|
||||||
<artifactId>authlib</artifactId>
|
<artifactId>authlib</artifactId>
|
||||||
<version>1.5.21</version>
|
<version>1.5.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
<version>2.2.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -15,11 +15,13 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.WorldSaveEvent;
|
import org.bukkit.event.world.WorldSaveEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public final class EnergeticStorage extends JavaPlugin implements Listener {
|
public final class EnergeticStorage extends JavaPlugin implements Listener {
|
||||||
private static EnergeticStorage plugin;
|
private static EnergeticStorage plugin;
|
||||||
|
public static final int BSTATS_PLUGIN_ID = 14068;
|
||||||
private static HopperTask hopperTask;
|
private static HopperTask hopperTask;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,6 +41,8 @@ public final class EnergeticStorage extends JavaPlugin implements Listener {
|
||||||
hopperTask = new HopperTask();
|
hopperTask = new HopperTask();
|
||||||
hopperTask.runTaskTimerAsynchronously(this, 0L, 8L);
|
hopperTask.runTaskTimerAsynchronously(this, 0L, 8L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
|
|
|
@ -154,7 +154,8 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
ESSystem esSystem = openSystems.get(player.getUniqueId());
|
ESSystem esSystem = openSystems.get(player.getUniqueId());
|
||||||
|
|
||||||
// Make sure no items will get copied to other players open inventory
|
// Make sure no items will get copied to other players open inventory
|
||||||
Inventory inv = player.getOpenInventory().getTopInventory();
|
Inventory thisInv = player.getOpenInventory().getTopInventory();
|
||||||
|
Inventory playerInv = player.getInventory();
|
||||||
|
|
||||||
// Handle type of click.
|
// Handle type of click.
|
||||||
switch (clickType) {
|
switch (clickType) {
|
||||||
|
@ -162,42 +163,21 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
break;
|
break;
|
||||||
case SWAP:
|
case SWAP:
|
||||||
break;
|
break;
|
||||||
|
case INVENTORY_CLICK:
|
||||||
case SHIFT_IN:
|
case SHIFT_IN:
|
||||||
|
case INTO_HALF:
|
||||||
|
case INTO:
|
||||||
if (Utils.isItemValid(clickedItem) && Utils.isItemADrive(clickedItem)) {
|
if (Utils.isItemValid(clickedItem) && Utils.isItemADrive(clickedItem)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Add the item into the player's inventory
|
int firstEmpty = thisInv.firstEmpty();
|
||||||
int driveSlot = inv.firstEmpty();
|
if (firstEmpty != -1) {
|
||||||
ItemStack oneClicked = clickedItem.clone();
|
thisInv.setItem(firstEmpty, clickedItem);
|
||||||
oneClicked.setAmount(1);
|
playerInv.removeItem(clickedItem);
|
||||||
inv.setItem(driveSlot, oneClicked);
|
|
||||||
|
|
||||||
List<ESDrive> drives = esSystem.getESDrives();
|
List<ESDrive> drives = esSystem.getESDrives();
|
||||||
drives.add(driveSlot - 2, new ESDrive(clickedItem));
|
drives.add(new ESDrive(clickedItem));
|
||||||
esSystem.setESDrives(drives);
|
esSystem.setESDrives(drives);
|
||||||
|
|
||||||
// Remove the item from the players inventory
|
|
||||||
clickedItem.setAmount(clickedItem.getAmount() - 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case INTO_HALF:
|
|
||||||
case INTO:
|
|
||||||
if (Utils.isItemValid(cursor) && Utils.isItemADrive(cursor)) {
|
|
||||||
NBTItem clickedNBT = new NBTItem(cursor);
|
|
||||||
|
|
||||||
if (clickedNBT.hasKey("ES_Drive") && clickedNBT.getBoolean("ES_Drive")) {
|
|
||||||
|
|
||||||
List<ESDrive> drives = esSystem.getESDrives();
|
|
||||||
if (drives.contains(null)) {
|
|
||||||
drives.set(drives.indexOf(null), new ESDrive(cursor));
|
|
||||||
} else {
|
|
||||||
drives.add(new ESDrive(cursor));
|
|
||||||
}
|
|
||||||
esSystem.setESDrives(drives);
|
|
||||||
initializeItems(player, esSystem);
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
cursor.setAmount(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -209,17 +189,20 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
||||||
|
|
||||||
Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
|
Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
|
||||||
} else if (slot != 1 && slot != 7 && slot != 8) {
|
} else if (slot != 1 && slot != 7 && slot != 8) {
|
||||||
if (Utils.isItemADrive(clickedItem)) {
|
if (Utils.isItemValid(clickedItem) && Utils.isItemADrive(clickedItem)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
int firstEmpty = playerInv.firstEmpty();
|
||||||
|
if (firstEmpty != -1) {
|
||||||
|
playerInv.setItem(firstEmpty, clickedItem);
|
||||||
|
thisInv.removeItem(clickedItem);
|
||||||
|
|
||||||
List<ESDrive> drives = esSystem.getESDrives();
|
List<ESDrive> drives = esSystem.getESDrives();
|
||||||
drives.set(slot - 2, null);
|
drives.set(slot - 2, null);
|
||||||
esSystem.setESDrives(drives);
|
esSystem.setESDrives(drives);
|
||||||
|
|
||||||
event.setCancelled(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case INVENTORY_CLICK:
|
|
||||||
event.setCancelled(false);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue