mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Improve furnace and hopper saving
- Fixed database syntax issue when getting the global top list
This commit is contained in:
parent
f1b1ba48e4
commit
ea3cc04998
17
pom.xml
17
pom.xml
@ -79,7 +79,7 @@
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<version>7.0.2-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>bukkit</artifactId>
|
||||
@ -107,21 +107,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-core</artifactId>
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>org.bukkit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bukkit-classloader-check</artifactId>
|
||||
<groupId>org.sk89q.bukkit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
|
@ -1635,11 +1635,14 @@ public abstract class JobsDAO {
|
||||
*/
|
||||
public List<TopList> getGlobalTopList(int start) {
|
||||
JobsConnection conn = getConnection();
|
||||
|
||||
List<TopList> names = new ArrayList<>();
|
||||
|
||||
if (conn == null)
|
||||
return names;
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
@ -1653,10 +1656,10 @@ public abstract class JobsDAO {
|
||||
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(res.getInt(JobsTableFields.userid.getCollumn()));
|
||||
if (info == null)
|
||||
continue;
|
||||
if (info.getName() == null)
|
||||
continue;
|
||||
|
||||
TopList top = new TopList(info, res.getInt("totallvl"), 0);
|
||||
names.add(top);
|
||||
|
||||
if (names.size() >= Jobs.getGCManager().JobsTopAmount)
|
||||
break;
|
||||
}
|
||||
@ -1666,6 +1669,7 @@ public abstract class JobsDAO {
|
||||
close(res);
|
||||
close(prest);
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
@ -1681,6 +1685,10 @@ public abstract class JobsDAO {
|
||||
if (conn == null)
|
||||
return names;
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
|
@ -297,9 +297,6 @@ public class JobsPaymentListener implements Listener {
|
||||
if (block == null || !Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign())
|
||||
return;
|
||||
|
||||
if (!block.hasMetadata(brewingOwnerMetadata))
|
||||
return;
|
||||
|
||||
@ -1004,9 +1001,6 @@ public class JobsPaymentListener implements Listener {
|
||||
if (block == null || !Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().isFurnacesReassign())
|
||||
return;
|
||||
|
||||
if (!block.hasMetadata(furnaceOwnerMetadata))
|
||||
return;
|
||||
|
||||
@ -1593,10 +1587,6 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(p.getWorld()))
|
||||
return;
|
||||
|
||||
@ -1641,17 +1631,17 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (cmat.equals(CMIMaterial.FURNACE) || cmat.equals(CMIMaterial.LEGACY_BURNING_FURNACE) || cmat.equals(CMIMaterial.SMOKER) || cmat.equals(CMIMaterial.BLAST_FURNACE)) {
|
||||
if (!Jobs.getGCManager().isFurnacesReassign())
|
||||
return;
|
||||
|
||||
if (cmat.equals(CMIMaterial.FURNACE) || cmat.equals(CMIMaterial.LEGACY_BURNING_FURNACE)
|
||||
|| cmat.equals(CMIMaterial.SMOKER) || cmat.equals(CMIMaterial.BLAST_FURNACE)) {
|
||||
ownershipFeedback done = FurnaceBrewingHandling.registerFurnaces(p, block);
|
||||
if (done.equals(ownershipFeedback.tooMany)) {
|
||||
boolean report = false;
|
||||
|
||||
if (block.hasMetadata(furnaceOwnerMetadata)) {
|
||||
List<MetadataValue> data = block.getMetadata(furnaceOwnerMetadata);
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
|
||||
// only care about first
|
||||
MetadataValue value = data.get(0);
|
||||
String uuid = value.asString();
|
||||
@ -1669,16 +1659,15 @@ public class JobsPaymentListener implements Listener {
|
||||
"[max]", jPlayer.getMaxFurnacesAllowed() == 0 ? "-" : jPlayer.getMaxFurnacesAllowed()));
|
||||
}
|
||||
} else if (cmat.equals(CMIMaterial.BREWING_STAND) || cmat.equals(CMIMaterial.LEGACY_BREWING_STAND)) {
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign())
|
||||
return;
|
||||
|
||||
ownershipFeedback done = FurnaceBrewingHandling.registerBrewingStand(p, block);
|
||||
if (done.equals(ownershipFeedback.tooMany)) {
|
||||
boolean report = false;
|
||||
|
||||
if (block.hasMetadata(brewingOwnerMetadata)) {
|
||||
List<MetadataValue> data = block.getMetadata(brewingOwnerMetadata);
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
|
||||
// only care about first
|
||||
MetadataValue value = data.get(0);
|
||||
String uuid = value.asString();
|
||||
@ -1717,7 +1706,6 @@ public class JobsPaymentListener implements Listener {
|
||||
Block b = loc.getBlock();
|
||||
if (b.getType().toString().startsWith("STRIPPED_") && jPlayer != null)
|
||||
Jobs.action(jPlayer, new BlockActionInfo(b, ActionType.STRIPLOGS), b);
|
||||
return;
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
@ -247,9 +247,7 @@ public class FurnaceBrewingHandling {
|
||||
return ownershipFeedback.invalid;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
int max = jPlayer.getMaxFurnacesAllowed();
|
||||
|
||||
int have = jPlayer.getFurnaceCount();
|
||||
|
||||
boolean owner = false;
|
||||
@ -277,24 +275,25 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), player.getUniqueId().toString()));
|
||||
|
||||
if (!Jobs.getGCManager().isFurnacesReassign()) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = furnaceMap.get(player.getUniqueId());
|
||||
if (ls == null)
|
||||
ls = new ArrayList<blockLoc>();
|
||||
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
furnaceMap.put(player.getUniqueId(), ls);
|
||||
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
public static ownershipFeedback registerBrewingStand(Player player, Block block) {
|
||||
|
||||
if (!CMIMaterial.get(block).equals(CMIMaterial.BREWING_STAND) && !CMIMaterial.get(block).equals(CMIMaterial.LEGACY_BREWING_STAND))
|
||||
return ownershipFeedback.invalid;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
|
||||
int max = jPlayer.getMaxBrewingStandsAllowed();
|
||||
|
||||
int have = jPlayer.getBrewingStandCount();
|
||||
|
||||
boolean owner = false;
|
||||
@ -313,6 +312,7 @@ public class FurnaceBrewingHandling {
|
||||
return ownershipFeedback.notOwn;
|
||||
}
|
||||
}
|
||||
|
||||
if (owner)
|
||||
return ownershipFeedback.old;
|
||||
|
||||
@ -321,12 +321,16 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), player.getUniqueId().toString()));
|
||||
|
||||
if (!Jobs.getGCManager().isBrewingStandsReassign()) {
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
List<blockLoc> ls = brewingMap.get(player.getUniqueId());
|
||||
if (ls == null)
|
||||
ls = new ArrayList<blockLoc>();
|
||||
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
brewingMap.put(player.getUniqueId(), ls);
|
||||
|
||||
return ownershipFeedback.newReg;
|
||||
}
|
||||
|
||||
@ -334,15 +338,19 @@ public class FurnaceBrewingHandling {
|
||||
List<blockLoc> ls = furnaceMap.remove(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
|
||||
for (blockLoc one : ls) {
|
||||
Block block = one.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
CMIMaterial cmat = CMIMaterial.get(block);
|
||||
if (!cmat.equals(CMIMaterial.FURNACE) && !cmat.equals(CMIMaterial.LEGACY_BURNING_FURNACE) && !cmat.equals(CMIMaterial.SMOKER) && !cmat.equals(CMIMaterial.BLAST_FURNACE))
|
||||
continue;
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
||||
}
|
||||
|
||||
return ls.size();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user