mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Fixes #392
This commit is contained in:
parent
857e7d29f4
commit
5ddb9db6ea
@ -103,5 +103,10 @@
|
|||||||
<version>1.5</version>
|
<version>1.5</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.3.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -26,6 +26,7 @@ import java.util.Comparator;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.events.PlotRateEvent;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.mutable.MutableInt;
|
import org.apache.commons.lang.mutable.MutableInt;
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.Rating;
|
import com.intellectualcrafters.plot.object.Rating;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class Rate extends SubCommand {
|
public class Rate extends SubCommand {
|
||||||
/*
|
/*
|
||||||
@ -116,9 +118,17 @@ public class Rate extends SubCommand {
|
|||||||
index.increment();
|
index.increment();
|
||||||
if (index.intValue() >= Settings.RATING_CATEGORIES.size()) {
|
if (index.intValue() >= Settings.RATING_CATEGORIES.size()) {
|
||||||
close();
|
close();
|
||||||
// set rating!
|
// handle ratings
|
||||||
plot.settings.ratings.put(player.getUUID(), rating.intValue());
|
int rV = rating.intValue();
|
||||||
DBFunc.setRating(plot, player.getUUID(), rating.intValue());
|
// CALL THE EVENT
|
||||||
|
PlotRateEvent rateEvent = new PlotRateEvent(player, rV, plot);
|
||||||
|
Bukkit.getPluginManager().callEvent(rateEvent);
|
||||||
|
// DONE CALLING THE EVENT
|
||||||
|
// get new rating
|
||||||
|
rV = rateEvent.getRating();
|
||||||
|
// set rating
|
||||||
|
plot.settings.ratings.put(player.getUUID(), rV);
|
||||||
|
DBFunc.setRating(plot, player.getUUID(), rV);
|
||||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||||
return false;
|
return false;
|
||||||
|
@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlayerLeavePlotEvent extends PlayerEvent {
|
public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||||
|
|
||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private final Plot plot;
|
private final Plot plot;
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlayerPlotDeniedEvent extends Event {
|
public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||||
|
|
||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private final Plot plot;
|
|
||||||
private final Player initiator;
|
private final Player initiator;
|
||||||
private final boolean added;
|
private final boolean added;
|
||||||
private final UUID player;
|
private final UUID player;
|
||||||
@ -48,8 +48,8 @@ public class PlayerPlotDeniedEvent extends Event {
|
|||||||
* @param added true of add to deny list, false if removed
|
* @param added true of add to deny list, false if removed
|
||||||
*/
|
*/
|
||||||
public PlayerPlotDeniedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
public PlayerPlotDeniedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||||
|
super(plot);
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.plot = plot;
|
|
||||||
this.added = added;
|
this.added = added;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
@ -76,15 +76,6 @@ public class PlayerPlotDeniedEvent extends Event {
|
|||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player initiating the action
|
* The player initiating the action
|
||||||
*
|
*
|
||||||
|
@ -32,9 +32,9 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class PlayerPlotHelperEvent extends Event {
|
public class PlayerPlotHelperEvent extends PlotEvent {
|
||||||
|
|
||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private final Plot plot;
|
|
||||||
private final Player initiator;
|
private final Player initiator;
|
||||||
private final boolean added;
|
private final boolean added;
|
||||||
private final UUID player;
|
private final UUID player;
|
||||||
@ -48,8 +48,8 @@ public class PlayerPlotHelperEvent extends Event {
|
|||||||
* @param added true of the player was added, false if the player was removed
|
* @param added true of the player was added, false if the player was removed
|
||||||
*/
|
*/
|
||||||
public PlayerPlotHelperEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
public PlayerPlotHelperEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||||
|
super(plot);
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.plot = plot;
|
|
||||||
this.added = added;
|
this.added = added;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
@ -76,15 +76,6 @@ public class PlayerPlotHelperEvent extends Event {
|
|||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player initiating the action
|
* The player initiating the action
|
||||||
*
|
*
|
||||||
|
@ -32,9 +32,9 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlayerPlotTrustedEvent extends Event {
|
public class PlayerPlotTrustedEvent extends PlotEvent {
|
||||||
|
|
||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private final Plot plot;
|
|
||||||
private final Player initiator;
|
private final Player initiator;
|
||||||
private final boolean added;
|
private final boolean added;
|
||||||
private final UUID player;
|
private final UUID player;
|
||||||
@ -48,8 +48,8 @@ public class PlayerPlotTrustedEvent extends Event {
|
|||||||
* @param added true of the player was added, false if the player was removed
|
* @param added true of the player was added, false if the player was removed
|
||||||
*/
|
*/
|
||||||
public PlayerPlotTrustedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
public PlayerPlotTrustedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||||
|
super(plot);
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.plot = plot;
|
|
||||||
this.added = added;
|
this.added = added;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
@ -76,15 +76,6 @@ public class PlayerPlotTrustedEvent extends Event {
|
|||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player initiating the action
|
* The player initiating the action
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.intellectualcrafters.plot.events;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.sk89q.worldedit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public abstract class PlotEvent extends Event {
|
||||||
|
|
||||||
|
private final Plot plot;
|
||||||
|
|
||||||
|
public PlotEvent(final Plot plot) {
|
||||||
|
this.plot = plot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Plot getPlot() {
|
||||||
|
return this.plot;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,9 +33,9 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlotFlagAddEvent extends Event implements Cancellable {
|
public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||||
|
|
||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private final Plot plot;
|
|
||||||
private final Flag flag;
|
private final Flag flag;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
|
|||||||
* @param plot Plot to which the flag was added
|
* @param plot Plot to which the flag was added
|
||||||
*/
|
*/
|
||||||
public PlotFlagAddEvent(final Flag flag, final Plot plot) {
|
public PlotFlagAddEvent(final Flag flag, final Plot plot) {
|
||||||
this.plot = plot;
|
super(plot);
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,15 +54,6 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the flag involved
|
* Get the flag involved
|
||||||
*
|
*
|
||||||
@ -78,12 +69,12 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public final boolean isCancelled() {
|
||||||
return this.cancelled;
|
return this.cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(final boolean b) {
|
public final void setCancelled(boolean cancelled) {
|
||||||
this.cancelled = b;
|
this.cancelled = cancelled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,9 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
|
||||||
|
|
||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private final Plot plot;
|
|
||||||
private final Flag flag;
|
private final Flag flag;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
|||||||
* @param plot Plot from which the flag was removed
|
* @param plot Plot from which the flag was removed
|
||||||
*/
|
*/
|
||||||
public PlotFlagRemoveEvent(final Flag flag, final Plot plot) {
|
public PlotFlagRemoveEvent(final Flag flag, final Plot plot) {
|
||||||
this.plot = plot;
|
super(plot);
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,14 +54,6 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plot involved
|
|
||||||
*
|
|
||||||
* @return Plot
|
|
||||||
*/
|
|
||||||
public Plot getPlot() {
|
|
||||||
return this.plot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the flag involved
|
* Get the flag involved
|
||||||
@ -78,12 +70,12 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public final boolean isCancelled() {
|
||||||
return this.cancelled;
|
return this.cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(final boolean b) {
|
public final void setCancelled(boolean cancelled) {
|
||||||
this.cancelled = b;
|
this.cancelled = cancelled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.intellectualcrafters.plot.events;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created 2015-07-13 for PlotSquaredGit
|
||||||
|
*
|
||||||
|
* @author Citymonstret
|
||||||
|
*/
|
||||||
|
public class PlotRateEvent extends PlotEvent {
|
||||||
|
|
||||||
|
private static HandlerList handlers = new HandlerList();
|
||||||
|
private final PlotPlayer rater;
|
||||||
|
private int rating;
|
||||||
|
|
||||||
|
public PlotRateEvent(final PlotPlayer rater, final int rating, final Plot plot) {
|
||||||
|
super(plot);
|
||||||
|
this.rater = rater;
|
||||||
|
this.rating = rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotPlayer getRater() {
|
||||||
|
return this.rater;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRating(int rating) {
|
||||||
|
this.rating = rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRating() {
|
||||||
|
return this.rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,22 +29,13 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
* String comparison library
|
* String comparison library
|
||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class StringComparison<T> {
|
public class StringComparison<T> {
|
||||||
/**
|
|
||||||
* Best Match
|
|
||||||
*/
|
|
||||||
private T bestMatch;
|
private T bestMatch;
|
||||||
/**
|
|
||||||
* Match Value
|
|
||||||
*
|
|
||||||
* Can be checked for low match (< .25 or something)
|
|
||||||
*/
|
|
||||||
private double match = Integer.MAX_VALUE;
|
private double match = Integer.MAX_VALUE;
|
||||||
/**
|
|
||||||
* The actual object
|
|
||||||
*/
|
|
||||||
private T bestMatchObject;
|
private T bestMatchObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,10 +146,20 @@ public class StringComparison<T> {
|
|||||||
return new ComparisonResult(this.match, this.bestMatch);
|
return new ComparisonResult(this.match, this.bestMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The comparison result
|
||||||
|
*/
|
||||||
public class ComparisonResult {
|
public class ComparisonResult {
|
||||||
public T best;
|
|
||||||
|
public final T best;
|
||||||
public final double match;
|
public final double match;
|
||||||
public ComparisonResult(double match, T best) {
|
|
||||||
|
/**
|
||||||
|
* The constructor
|
||||||
|
* @param match Match value
|
||||||
|
* @param best Best Match
|
||||||
|
*/
|
||||||
|
public ComparisonResult(final double match, final T best) {
|
||||||
this.match = match;
|
this.match = match;
|
||||||
this.best = best;
|
this.best = best;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user