12
1

Reduce overhead and add a World of Colors!

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-08-31 11:19:56 +02:00
Ursprung 96bd358d29
Commit 765a9e4f6c
15 geänderte Dateien mit 78 neuen und 179 gelöschten Zeilen

Datei anzeigen

@ -1,31 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.fight;
import org.bukkit.ChatColor;
import org.bukkit.scoreboard.Team;
public class FightTeam12 implements FightTeam.IFightTeam {
@Override
public void setTeamColor(Team team, ChatColor color){
team.setColor(color);
}
}

Datei anzeigen

@ -17,11 +17,17 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
package de.steamwar.fightsystem.utils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Arrow;
import org.bukkit.scoreboard.Team;
public class ArrowStopper12 implements ArrowStopper.IArrowStopper {
public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorWrapper {
@Override
public void setTeamColor(Team team, ChatColor color) {
team.setColor(color);
}
@Override
public boolean isInBlock(Arrow e) {

Datei anzeigen

@ -1,25 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import org.bukkit.event.Listener;
public class ArrowPickup8 implements Listener {
}

Datei anzeigen

@ -1,25 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import org.bukkit.event.Listener;
public class DenyWorldInteraction8 implements Listener {
}

Datei anzeigen

@ -26,6 +26,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scoreboard.Team;
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
@ -55,4 +56,14 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
public void setNametagVisibility(Team team) {
//nothing to do
}
@Override
public Listener newDenyArrowPickupListener() {
return new Listener() {};
}
@Override
public Listener newDenyHandSwapListener() {
return new Listener() {};
}
}

Datei anzeigen

@ -17,11 +17,18 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
package de.steamwar.fightsystem.utils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Arrow;
import org.bukkit.scoreboard.Team;
public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWrapper {
@Override
public void setTeamColor(Team team, ChatColor color) {
team.setPrefix("§" + color.getChar());
}
public class ArrowStopper8 implements ArrowStopper.IArrowStopper {
@Override
public boolean isInBlock(Arrow e) {
return false;

Datei anzeigen

@ -1,32 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupArrowEvent;
public class ArrowPickup9 implements Listener {
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){
e.setCancelled(true);
}
}

Datei anzeigen

@ -1,32 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
public class DenyWorldInteraction9 implements Listener {
@EventHandler
public void onSwapItems(PlayerSwapHandItemsEvent event) {
event.setCancelled(true);
}
}

Datei anzeigen

@ -26,6 +26,10 @@ import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupArrowEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.scoreboard.Team;
public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
@ -55,4 +59,24 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
public void setNametagVisibility(Team team) {
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
}
@Override
public Listener newDenyArrowPickupListener() {
return new Listener() {
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){
e.setCancelled(true);
}
};
}
@Override
public Listener newDenyHandSwapListener() {
return new Listener() {
@EventHandler
public void onSwapItems(PlayerSwapHandItemsEvent event) {
event.setCancelled(true);
}
};
}
}

Datei anzeigen

@ -24,17 +24,13 @@ import de.steamwar.comms.packets.TablistNamePacket;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.ItemBuilder;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
@ -50,8 +46,6 @@ import java.util.*;
public class FightTeam {
private static final IFightTeam impl = VersionDependent.getVersionImpl(FightTeam.class.getName());
private UUID designatedLeader;
private FightPlayer leader;
private final Map<Player, FightPlayer> players = new HashMap<>();
@ -89,7 +83,7 @@ public class FightTeam {
else
team = FightScoreboard.getBukkit().getTeam(name);
assert team != null;
impl.setTeamColor(team, color);
WorldOfColorWrapper.impl.setTeamColor(team, color);
BountifulWrapper.impl.setNametagVisibility(team);
//noinspection deprecation
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
@ -406,10 +400,6 @@ public class FightTeam {
return color;
}
public interface IFightTeam {
void setTeamColor(Team team, ChatColor color);
}
private class KitLoader extends StateDependent {
private KitLoader() {
super(ArenaMode.AntiReplay, FightState.Ingame);

Datei anzeigen

@ -20,13 +20,13 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.BountifulWrapper;
public class ArrowPickup {
public ArrowPickup() {
new StateDependentListener(ArenaMode.All, FightState.All, VersionDependent.getVersionImpl(ArrowPickup.class.getName()));
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
}
}

Datei anzeigen

@ -20,9 +20,9 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.WorldOfColorWrapper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -37,8 +37,6 @@ public class ArrowStopper {
private static final Vector NULL_VECTOR = new Vector(0, 0, 0);
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
private static final IArrowStopper impl = VersionDependent.getVersionImpl(ArrowStopper.class.getName());
public ArrowStopper() {
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
}
@ -93,7 +91,7 @@ public class ArrowStopper {
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ();
boolean otherSide = teamFrom == overMid;
return otherSide ||
impl.isInBlock(entity) ||
WorldOfColorWrapper.impl.isInBlock(entity) ||
entity.getVelocity().equals(NULL_VECTOR);
}

Datei anzeigen

@ -20,9 +20,9 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.VersionDependent;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -41,7 +41,7 @@ public class DenyWorldInteraction implements Listener {
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
Listener listener = VersionDependent.getVersionImpl(DenyWorldInteraction.class.getName());
Listener listener = BountifulWrapper.impl.newDenyHandSwapListener();
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
}

Datei anzeigen

@ -23,6 +23,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
import de.steamwar.fightsystem.VersionDependent;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scoreboard.Team;
public class BountifulWrapper {
@ -39,5 +40,8 @@ public class BountifulWrapper {
void setAttackSpeed(Player player);
void setNametagVisibility(Team team);
Listener newDenyArrowPickupListener();
Listener newDenyHandSwapListener();
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2021 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@ -15,18 +15,22 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
*/
package de.steamwar.fightsystem.fight;
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.VersionDependent;
import org.bukkit.ChatColor;
import org.bukkit.entity.Arrow;
import org.bukkit.scoreboard.Team;
public class FightTeam8 implements FightTeam.IFightTeam {
public class WorldOfColorWrapper {
private WorldOfColorWrapper() {}
@Override
public void setTeamColor(Team team, ChatColor color){
team.setPrefix("§" + color.getChar());
public static final IWorldOfColorWrapper impl = VersionDependent.getVersionImpl(WorldOfColorWrapper.class.getName());
public interface IWorldOfColorWrapper {
void setTeamColor(Team team, ChatColor color);
boolean isInBlock(Arrow e);
}
}