mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 13:05:41 +01:00
Fixes #518
This commit is contained in:
parent
64063463ec
commit
a2b29da39d
@ -39,6 +39,7 @@ import com.intellectualcrafters.plot.object.PlotInventory;
|
||||
import com.intellectualcrafters.plot.object.PlotItemStack;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
@ -121,14 +122,9 @@ public class Rate extends SubCommand {
|
||||
index.increment();
|
||||
if (index.intValue() >= Settings.RATING_CATEGORIES.size()) {
|
||||
close();
|
||||
// handle ratings
|
||||
int rV = rating.intValue();
|
||||
// CALL THE EVENT
|
||||
PlotRateEvent rateEvent = new PlotRateEvent(player, new Rating(rV), plot);
|
||||
Bukkit.getPluginManager().callEvent(rateEvent);
|
||||
// DONE CALLING THE EVENT
|
||||
// set rating
|
||||
plot.getSettings().ratings.put(player.getUUID(), rateEvent.getRating().getAggregate());
|
||||
Rating result = EventUtil.manager.callRating(player, plot, new Rating(rV));
|
||||
plot.getSettings().ratings.put(player.getUUID(), result.getAggregate());
|
||||
DBFunc.setRating(plot, player.getUUID(), rV);
|
||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||
@ -192,8 +188,10 @@ public class Rate extends SubCommand {
|
||||
sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||
return;
|
||||
}
|
||||
plot.getSettings().ratings.put(uuid, rating);
|
||||
DBFunc.setRating(plot, uuid, rating);
|
||||
Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
||||
int resultVal = result.getAggregate();
|
||||
plot.getSettings().ratings.put(uuid, resultVal);
|
||||
DBFunc.setRating(plot, uuid, resultVal);
|
||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||
}
|
||||
};
|
||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.plotsquared.bukkit.listeners.PlayerBlockEventType;
|
||||
|
||||
public abstract class EventUtil {
|
||||
@ -29,6 +30,8 @@ public abstract class EventUtil {
|
||||
PS.get().IMP.unregister(player);
|
||||
}
|
||||
|
||||
public abstract Rating callRating(final PlotPlayer player, final Plot plot, final Rating rating);
|
||||
|
||||
public abstract boolean callClaim(final PlotPlayer player, final Plot plot, final boolean auto);
|
||||
|
||||
public abstract boolean callTeleport(final PlotPlayer player, Location from, final Plot plot);
|
||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.plotsquared.bukkit.events.ClusterFlagRemoveEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerClaimPlotEvent;
|
||||
@ -28,6 +29,7 @@ import com.plotsquared.bukkit.events.PlotDeleteEvent;
|
||||
import com.plotsquared.bukkit.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.bukkit.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.bukkit.events.PlotMergeEvent;
|
||||
import com.plotsquared.bukkit.events.PlotRateEvent;
|
||||
import com.plotsquared.bukkit.events.PlotUnlinkEvent;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
|
||||
@ -118,4 +120,11 @@ public class BukkitEventUtil extends EventUtil {
|
||||
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
return event.getRating();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.events.ClusterFlagRemoveEvent;
|
||||
@ -28,6 +29,7 @@ import com.plotsquared.sponge.events.PlotDeleteEvent;
|
||||
import com.plotsquared.sponge.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.sponge.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.sponge.events.PlotMergeEvent;
|
||||
import com.plotsquared.sponge.events.PlotRateEvent;
|
||||
import com.plotsquared.sponge.events.PlotUnlinkEvent;
|
||||
|
||||
public class SpongeEventUtil extends EventUtil {
|
||||
@ -116,4 +118,11 @@ public class SpongeEventUtil extends EventUtil {
|
||||
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||
events.post(event);
|
||||
return event.getRating();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user