This commit is contained in:
Anuken
2019-09-01 15:52:07 -04:00
parent 494c3ffbc4
commit e8d89b6c43
5 changed files with 19 additions and 11 deletions

View File

@@ -228,7 +228,7 @@ public class NetServer implements ApplicationListener{
});
//duration of a a kick in seconds
int kickDuration = 10 * 60;
int kickDuration = 15 * 60;
class VoteSession{
Player target;
@@ -243,9 +243,9 @@ public class NetServer implements ApplicationListener{
this.task = Timer.schedule(() -> {
if(!checkPass()){
Call.sendMessage(Strings.format("[lightgray]Vote failed. Not enough votes to kick[orange] {0}[lightgray].", target.name));
map.remove(target);
task.cancel();
}
map.remove(target);
task.cancel();
}, 60 * 1.5f);
}
@@ -254,6 +254,8 @@ public class NetServer implements ApplicationListener{
Call.sendMessage(Strings.format("[orange]Vote passed.[scarlet] {0}[orange] will be kicked from the server.", target.name));
admins.getInfo(target.uuid).lastKicked = Time.millis() + kickDuration*1000;
kick(target.con.id, KickReason.vote);
map.remove(target);
task.cancel();
return true;
}
return false;
@@ -272,6 +274,11 @@ public class NetServer implements ApplicationListener{
return;
}
if(player.isLocal){
player.sendMessage("[scarlet]Just kick them yourself if you're the host.");
return;
}
if(currentlyKicking.values().toArray().contains(v -> v.voted.contains(player.uuid) || v.voted.contains(admins.getInfo(player.uuid).lastIP))){
player.sendMessage("[scarlet]You've already voted. Sit down.");
return;
@@ -296,10 +303,10 @@ public class NetServer implements ApplicationListener{
}
if(found != null){
if(player == found){
player.sendMessage("[scarlet]If you're interested in kicking yourself, just leave.");
}else if(found.isAdmin){
if(found.isAdmin){
player.sendMessage("[scarlet]Did you really expect to be able to kick an admin?");
}else if(found.isLocal){
player.sendMessage("[scarlet]Local players cannot be kicked.");
}else{
if(!currentlyKicking.containsKey(found) && !vtime.get()){
player.sendMessage("[scarlet]You must wait " + voteTime/60 + " minutes between votekicks.");

View File

@@ -58,7 +58,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
//visual only.
if(Net.client()){
Tile tile = world.tile(unit.spawner);
if(tile != null && !Net.client()){
if(tile != null){
tile.block().unitRemoved(tile, unit);
}

View File

@@ -37,6 +37,7 @@ import static io.anuke.mindustry.Vars.*;
public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
public static final int timerSync = 2;
public static final int timerAbility = 3;
public static final int timerTransfer = 4;
private static final int timerShootLeft = 0;
private static final int timerShootRight = 1;
private static final float liftoffBoost = 0.2f;
@@ -59,7 +60,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
public NetConnection con;
public boolean isLocal = false;
public Interval timer = new Interval(4);
public Interval timer = new Interval(6);
public TargetTrait target;
public TargetTrait moveTarget;

View File

@@ -59,7 +59,7 @@ public abstract class InputHandler implements InputProcessor{
@Remote(targets = Loc.both, forward = true, called = Loc.server)
public static void transferInventory(Player player, Tile tile){
if(Net.server() && (player.item().amount <= 0 || player.isTransferring)){
if(Net.server() && (player.item().amount <= 0 || player.isTransferring || !player.timer.get(Player.timerTransfer, 40))){
throw new ValidateException(player, "Player cannot transfer an item.");
}
@@ -288,7 +288,7 @@ public abstract class InputHandler implements InputProcessor{
}
public void tryDropItems(Tile tile, float x, float y){
if(!droppingItem || player.item().amount <= 0 || canTapPlayer(x, y) || state.isPaused()){
if(!droppingItem || player.item().amount <= 0 || canTapPlayer(x, y) || state.isPaused() || !player.timer.check(Player.timerTransfer, 40)){
droppingItem = false;
return;
}

View File

@@ -40,7 +40,7 @@ public class BlockInventoryFragment extends Fragment{
@Remote(called = Loc.server, targets = Loc.both, forward = true)
public static void requestItem(Player player, Tile tile, Item item, int amount){
if(player == null || tile == null) return;
if(player == null || tile == null || !player.timer.get(Player.timerTransfer, 20)) return;
int removed = tile.block().removeStack(tile, item, amount);